MCPcopy Create free account
hub / github.com/HumbleUI/Skija / drawSubset

Method drawSubset

examples/scenes/src/BitmapScene.java:162–179  ·  view source on GitHub ↗
(Canvas canvas, IRect target, IRect screen, float dpi)

Source from the content-addressed store, hash-verified

160 }
161
162 public void drawSubset(Canvas canvas, IRect target, IRect screen, float dpi) {
163 try (var src = new Bitmap();
164 var dst = new Bitmap();)
165 {
166 var srcInfo = ImageInfo.makeS32((int) (target.getWidth() * dpi), (int) (target.getHeight() * dpi), ColorAlphaType.OPAQUE);
167 src.allocPixels(srcInfo);
168 if (canvas.readPixels(src, (int) (target.getLeft() * dpi), (int) (target.getTop() * dpi))) {
169 src.extractSubset(dst, Rect.makeXYWH(target.getWidth() / 4 * dpi, target.getHeight() / 4 * dpi, target.getWidth() / 2 * dpi, target.getHeight() / 2 * dpi).toIRect());
170 try (var image = Image.makeRasterFromBitmap(dst.setImmutable());) {
171 canvas.drawImageRect(image, target.toRect());
172 }
173 }
174 }
175
176 try(var stroke = new Paint().setColor(0xFFE5E5E5).setMode(PaintMode.STROKE).setStrokeWidth(1);) {
177 canvas.drawRect(target.toRect(), stroke);
178 }
179 }
180
181 public void drawPixelRef(Canvas canvas, IRect target, IRect screen, float dpi) {
182 try (var src = new Bitmap();

Callers 1

drawMethod · 0.95

Calls 13

makeS32Method · 0.95
makeRasterFromBitmapMethod · 0.95
allocPixelsMethod · 0.80
drawImageRectMethod · 0.80
setStrokeWidthMethod · 0.80
setModeMethod · 0.80
drawRectMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
readPixelsMethod · 0.45
extractSubsetMethod · 0.45
setImmutableMethod · 0.45

Tested by

no test coverage detected