1 | static BufferedImage resizeImage(BufferedImage img, int newW, int newH) { |
2 | ret resizeImage(img, newW, newH, Image.SCALE_SMOOTH); |
3 | } |
4 | |
5 | static BufferedImage resizeImage(BufferedImage img, int newW, int newH, int scaleType) { |
6 | if (newW == img.getWidth() && newH == img.getHeight()) ret img; |
7 | Image tmp = img.getScaledInstance(newW, newH, scaleType); |
8 | BufferedImage dimg = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_ARGB); |
9 | Graphics2D g2d = dimg.createGraphics(); |
10 | g2d.drawImage(tmp, 0, 0, null); |
11 | g2d.dispose(); |
12 | return dimg; |
13 | } |
14 | |
15 | static BufferedImage resizeImage(BufferedImage img, int newW) { |
16 | int newH = iround(img.getHeight()*(double) newW/img.getWidth()); |
17 | ret resizeImage(img, newW, newH); |
18 | } |
19 | |
20 | static BufferedImage resizeImage(int newW, BufferedImage img) { |
21 | ret resizeImage(img, newW); |
22 | } |
Began life as a copy of #1004222
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, ofpaelxlmzfo, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004224 |
Snippet name: | resizeImage - preserves transparency, defaults to smooth scaling |
Eternal ID of this version: | #1004224/5 |
Text MD5: | 31667d22d9bfde18bb1283a2c84ed848 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-02-28 16:31:27 |
Source code size: | 828 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 946 / 911 |
Version history: | 4 change(s) |
Referenced in: | [show references] |