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

7
LINES

< > BotCompany Repo | #1032347 // cropToSquare

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

Libraryless. Click here for Pure Java version (420L/3K).

static BufferedImage cropToSquare(BufferedImage img) {
  if (img == null) null;
  int w = img.getWidth(), h = img.getHeight();
  int newSize = min(w, h);
  Rect r = new Rect(0, 0, newSize, newSize);
  ret clipBufferedImage(img, centerRectInRect(r, imageRect(img)));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032347
Snippet name: cropToSquare
Eternal ID of this version: #1032347/2
Text MD5: fb04109568ef6e92c20fb3da61e7fa72
Transpilation MD5: ce964acabf80a95843989ccbee14b17f
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-30 01:46:46
Source code size: 273 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 139 / 190
Version history: 1 change(s)
Referenced in: [show references]