Libraryless. Click here for Pure Java version (420L/3K).
1 | static BufferedImage cropToSquare(BufferedImage img) { |
2 | if (img == null) null; |
3 | int w = img.getWidth(), h = img.getHeight(); |
4 | int newSize = min(w, h); |
5 | Rect r = new Rect(0, 0, newSize, newSize); |
6 | ret clipBufferedImage(img, centerRectInRect(r, imageRect(img))); |
7 | } |
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: | 141 / 194 |
Version history: | 1 change(s) |
Referenced in: | [show references] |