Libraryless. Click here for Pure Java version (9242L/51K).
1 | svoid drawScaledPixelatedImage(Graphics2D etc g, BufferedImage img, Rect r) { |
2 | if (g == null || img == null || r == null) ret; |
3 | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
4 | double scaleX = doubleRatio(r.w, img.getWidth()); |
5 | double scaleY = doubleRatio(r.h, img.getHeight()); |
6 | //print("drawScaledPixelatedImage: " + r + " " + scaleX + "/" + scaleY); |
7 | g.translate(r.x, r.y); |
8 | g.scale(scaleX, scaleY); |
9 | g.drawImage(img, 0, 0, null); |
10 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019542 |
Snippet name: | drawScaledPixelatedImage |
Eternal ID of this version: | #1019542/7 |
Text MD5: | 137b3c4fce88cc3881f37c69214761f2 |
Transpilation MD5: | 849d692f245b6cc00eecd4969406b3ba |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-05 03:04:16 |
Source code size: | 511 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 279 / 368 |
Version history: | 6 change(s) |
Referenced in: | [show references] |