Libraryless. Click here for Pure Java version (2966L/17K).
1 | svoid drawScaledImage(BufferedImage canvas, BufferedImage img, Rect r) { |
2 | if (canvas == null || img == null || r == null) ret; |
3 | Graphics2D g = createGraphics(canvas); |
4 | drawScaledImage(g, img, r); |
5 | } |
6 | |
7 | svoid drawScaledImage(Graphics2D g, BufferedImage img, Rect r) { |
8 | if (g == null || img == null || r == null) ret; |
9 | double scaleX = doubleRatio(r.w, img.getWidth()); |
10 | double scaleY = doubleRatio(r.h, img.getHeight()); |
11 | g.translate(r.x, r.y); |
12 | g.scale(scaleX, scaleY); |
13 | g.drawImage(img, 0, 0, null); |
14 | } |
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: | 134 / 183 |
Version history: | 1 change(s) |
Referenced in: | [show references] |