mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-02 02:14:36 -05:00
Basic android.graphics Rect and Canvas implementation (#461)
Some extensions use more Canvas methods, but they don't really seem to get that far yet, all the others I was able to test seem to work now.
This commit is contained in:
21
AndroidCompat/src/main/java/android/graphics/Canvas.java
Normal file
21
AndroidCompat/src/main/java/android/graphics/Canvas.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package android.graphics;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public final class Canvas {
|
||||
private BufferedImage canvasImage;
|
||||
private Graphics2D canvas;
|
||||
|
||||
public Canvas(Bitmap bitmap) {
|
||||
canvasImage = bitmap.getImage();
|
||||
canvas = canvasImage.createGraphics();
|
||||
}
|
||||
|
||||
public void drawBitmap(Bitmap sourceBitmap, Rect src, Rect dst, Paint paint) {
|
||||
BufferedImage sourceImage = sourceBitmap.getImage();
|
||||
BufferedImage sourceImageCropped = sourceImage.getSubimage(src.left, src.top, src.getWidth(), src.getHeight());
|
||||
canvas.drawImage(sourceImageCropped, null, dst.left, dst.top);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user