Libraryless. Compilation Failed (9824L/55K).
srecord noeq PadImageToAspectRatio(BufferedImage img, Ratio ratio, Color color) > Meta { BufferedImage out; *(BufferedImage *img, double ratio, Color *color) { this.ratio = Ratio(ratio); } BufferedImage get() { int w = img.getWidth(), h = img.getHeight(); double actualRatio = doubleRatio(w, h); double targetRatio = this.ratio!; int w2 = w, h2 = h; if (targetRatio > actualRatio) // target ratio is wider w2 = iround(h2*targetRatio); else h2 = iround(w2/targetRatio); if (scaffolding()) printVars(+w, +h, +w2, +h2, +actualRatio, +targetRatio, ratio := this.ratio); if (w == w2 && h == h2) ret img; out = isFullyTransparent(color) ? newTransparentImage(w2, h2) : newImage(w2, h2, color); drawImageOnImage(img, out, (w2-w)/2, (h2-h)/2); ret out; } }
Began life as a copy of #1007278
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034776 |
Snippet name: | PadImageToAspectRatio |
Eternal ID of this version: | #1034776/9 |
Text MD5: | e5b14bd6baa0a50143a39a991645ee50 |
Transpilation MD5: | 25c145057474e99672538fd9304b9d1b |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-12 18:33:36 |
Source code size: | 874 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 176 / 305 |
Version history: | 8 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |