Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

7
LINES

< > BotCompany Repo | #1033900 // resizeImageIcon

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (7100L/42K).

1  
// works for .gif also. SCALE_DEFAULT has to be used
2  
// (https://stackoverflow.com/questions/9392227/resizing-animated-gif-while-keeping-its-animation-using-java)
3  
static ImageIcon resizeImageIcon(ImageIcon icon, int newW) {
4  
  var img = icon.getImage();
5  
  int newH = iround(img.getHeight(null)*(double) newW/img.getWidth(null));
6  
  ret imageIcon(resizeImage_raw(img, newW, newH, Image.SCALE_DEFAULT));
7  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033900
Snippet name: resizeImageIcon
Eternal ID of this version: #1033900/4
Text MD5: d74fb373c8d7eda90e3d5459a4f3af95
Transpilation MD5: e86b11237817090d72815d3a90d7effb
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-09 19:24:29
Source code size: 407 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 158 / 212
Version history: 3 change(s)
Referenced in: [show references]