(Canvas canvas, int width, int height, float dpi, int xpos, int ypos)
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public void draw(Canvas canvas, int width, int height, float dpi, int xpos, int ypos) { |
| 36 | canvas.save(); |
| 37 | canvas.translate(20, 20); |
| 38 | x = 20; |
| 39 | y = 20; |
| 40 | |
| 41 | // Image |
| 42 | canvas.drawImageRect(image, Rect.makeXYWH(0, 0, 200, 200)); |
| 43 | canvas.drawString("Image", 0, 220, inter13, blackFill); |
| 44 | advance(canvas, width); |
| 45 | |
| 46 | // Bitmap + Image.readPixels |
| 47 | try (var bitmap = new Bitmap();) { |
| 48 | bitmap.allocPixels(ImageInfo.makeS32(400, 400, ColorAlphaType.OPAQUE)); |
| 49 | image.readPixels(bitmap); |
| 50 | try (var image = Image.makeFromBitmap(bitmap.setImmutable());) { |
| 51 | canvas.drawImageRect(image, Rect.makeXYWH(0, 0, 200, 200)); |
| 52 | } |
| 53 | canvas.drawString("Image.readPixels", 0, 220, inter13, blackFill); |
| 54 | advance(canvas, width); |
| 55 | } |
| 56 | |
| 57 | // Bitmap + Image.readPixels(50, 50) |
| 58 | try (var bitmap = new Bitmap();) { |
| 59 | bitmap.allocPixels(new ImageInfo(300, 300, ColorType.GRAY_8, ColorAlphaType.OPAQUE)); |
| 60 | image.readPixels(bitmap, 50, 50); |
| 61 | try (var image = Image.makeFromBitmap(bitmap.setImmutable());) { |
| 62 | canvas.drawImageRect(image, Rect.makeXYWH(25, 25, 150, 150)); |
| 63 | } |
| 64 | canvas.drawString("Image.readPixels(50, 50)", 0, 220, inter13, blackFill); |
| 65 | advance(canvas, width); |
| 66 | } |
| 67 | |
| 68 | byte[] pixels; |
| 69 | ImageInfo info; |
| 70 | |
| 71 | // Bitmap readPixels/installPixels |
| 72 | try (var bitmap = Bitmap.makeFromImage(image);) { |
| 73 | info = bitmap.getImageInfo(); |
| 74 | pixels = bitmap.readPixels(); |
| 75 | pixelSorting(canvas, ByteBuffer.wrap(pixels), info); |
| 76 | bitmap.installPixels(pixels); |
| 77 | try (var image = Image.makeFromBitmap(bitmap.setImmutable());) { |
| 78 | canvas.drawImageRect(image, Rect.makeXYWH(0, 0, 200, 200)); |
| 79 | } |
| 80 | canvas.drawString("Bitmap.readPixels/installPixels", 0, 220, inter13, blackFill); |
| 81 | advance(canvas, width); |
| 82 | } |
| 83 | |
| 84 | // Bitmap peekPixels |
| 85 | try (var bitmap = Bitmap.makeFromImage(image);) { |
| 86 | pixelSorting(canvas, bitmap.peekPixels(), bitmap.getImageInfo()); |
| 87 | try (var image = Image.makeFromBitmap(bitmap.setImmutable());) { |
| 88 | canvas.drawImageRect(image, Rect.makeXYWH(0, 0, 200, 200)); |
| 89 | } |
| 90 | canvas.drawString("Bitmap.peekPixels", 0, 220, inter13, blackFill); |
| 91 | advance(canvas, width); |
nothing calls this directly
no test coverage detected