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

17
LINES

< > BotCompany Repo | #1033899 // resizeImage_raw - preserves transparency, defaults to smooth scaling

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

Libraryless. Click here for Pure Java version (4610L/26K).

1  
static Image resizeImage_raw(Image img, int newW, int newH) {
2  
  ret resizeImage_raw(img, newW, newH, Image.SCALE_SMOOTH);
3  
}
4  
5  
static Image resizeImage_raw(Image img, int newW, int newH, int scaleType) {
6  
  if (newW == img.getWidth(null) && newH == img.getHeight(null)) ret img;
7  
  ret img.getScaledInstance(newW, newH, scaleType);
8  
}
9  
10  
static Image resizeImage_raw(Image img, int newW) {
11  
  int newH = iround(img.getHeight(null)*(double) newW/img.getWidth(null));
12  
  ret resizeImage_raw(img, newW, newH);
13  
}
14  
15  
static Image resizeImage_raw(int newW, Image img) {
16  
  ret resizeImage_raw(img, newW);
17  
}

Author comment

Began life as a copy of #1004224

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033899
Snippet name: resizeImage_raw - preserves transparency, defaults to smooth scaling
Eternal ID of this version: #1033899/5
Text MD5: 1ccca00195a30cb6ed721c944a944887
Transpilation MD5: 95f4596996062f6ac9bdb6a1745b0fac
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-09 19:17:59
Source code size: 604 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 236
Version history: 4 change(s)
Referenced in: [show references]