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

13
LINES

< > BotCompany Repo | #1033311 // scaleImageWithOp

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

Libraryless. Click here for Pure Java version (3852L/22K).

import java.awt.geom.*;

static BufferedImage scaleImageWithOp(BufferedImage before, double scaleX, double scaleY default scaleX, int affineTransformOpType) {
  if (scaleX == 1 && scaleY == 1) ret before;
  int w = before.getWidth();
  int h = before.getHeight();
  int neww = max(1, iround(w*scaleX)), newh = max(1, iround(h*scaleY));
  BufferedImage after = new BufferedImage(neww, newh, BufferedImage.TYPE_INT_ARGB);
  AffineTransform at = new AffineTransform();
  at.scale(scaleX, scaleY);
  AffineTransformOp scaleOp = new(at, affineTransformOpType);
  ret scaleOp.filter(before, after);
}

Author comment

Began life as a copy of #1003737

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033311
Snippet name: scaleImageWithOp
Eternal ID of this version: #1033311/1
Text MD5: fda2e4e6a1ce38022f57c477d99520b1
Transpilation MD5: 774cbec8fa43489d4bea6cd2c22e62bf
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-22 20:56:59
Source code size: 606 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 154 / 227
Referenced in: [show references]