static BufferedImage resizeImage(BufferedImage img, int newW, int newH) { ret resizeImage(img, newW, newH, Image.SCALE_SMOOTH); } static BufferedImage resizeImage(BufferedImage img, int newW, int newH, int scaleType) { if (newW == img.getWidth() && newH == img.getHeight()) ret img; Image tmp = img.getScaledInstance(newW, newH, scaleType); BufferedImage dimg = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = dimg.createGraphics(); g2d.drawImage(tmp, 0, 0, null); g2d.dispose(); return dimg; } static BufferedImage resizeImage(BufferedImage img, int newW) { int newH = iround(img.getHeight()*(double) newW/img.getWidth()); ret resizeImage(img, newW, newH); } static BufferedImage resizeImage(int newW, BufferedImage img) { ret resizeImage(img, newW); }
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: | 945 / 909 |
Version history: | 4 change(s) |
Referenced in: | [show references] |