Libraryless. Click here for Pure Java version (2966L/17K).
svoid drawScaledImage(BufferedImage canvas, BufferedImage img, Rect r) { if (canvas == null || img == null || r == null) ret; Graphics2D g = createGraphics(canvas); drawScaledImage(g, img, r); } svoid drawScaledImage(Graphics2D g, BufferedImage img, Rect r) { if (g == null || img == null || r == null) ret; double scaleX = doubleRatio(r.w, img.getWidth()); double scaleY = doubleRatio(r.h, img.getHeight()); g.translate(r.x, r.y); g.scale(scaleX, scaleY); g.drawImage(img, 0, 0, null); }
Began life as a copy of #1019542
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031217 |
Snippet name: | drawScaledImage |
Eternal ID of this version: | #1031217/2 |
Text MD5: | 828728d88acb01520ac2d30772b3d6f5 |
Transpilation MD5: | 3d720082e696236e45051cf767172f6c |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-20 21:25:21 |
Source code size: | 520 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 133 / 181 |
Version history: | 1 change(s) |
Referenced in: | [show references] |