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

15
LINES

< > BotCompany Repo | #1015057 // scaleBufferedImageToMaxWidthOrHeight

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

Transpiled version (9246L) is out of date.

static BufferedImage scaleBufferedImageToMaxWidthOrHeight(WidthAndHeight size, BufferedImage img) {
  ret img == null ?: scaleBufferedImageToMaxWidthOrHeight(size.w(), size.h(), img);
}

static BufferedImage scaleBufferedImageToMaxWidthOrHeight(int maxW, int maxH default maxW, BufferedImage img) {
  if (img == null) null;
  int w = img.getWidth(), h = img.getHeight();
  if (w <= maxW && h <= maxH) ret img;
  double scale = min(doubleRatio(maxW, w), doubleRatio(maxH, h));
  ret scaleImage(img, scale);
}

static BufferedImage scaleBufferedImageToMaxWidthOrHeight(BufferedImage img, int max) {
  ret scaleBufferedImageToMaxWidthOrHeight(max, img);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015057
Snippet name: scaleBufferedImageToMaxWidthOrHeight
Eternal ID of this version: #1015057/6
Text MD5: 68495bce051bd30d667bcbf0037a78ed
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-05 16:41:58
Source code size: 668 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 422 / 523
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1015074 - scaleBufferedImageToMax - synonym of scaleBufferedImageToMaxWidthOrHeight
#1015385 - scaleBufferedImageToHeight
#1015443 - scaleBufferedImageToMaxPixels
#1034222 - scaleBufferedImageToFit