Libraryless. Click here for Pure Java version (5006L/28K).
1 | static Pt calcFitSize(BufferedImage image, Component c) {
|
2 | ret calcFitSize(image, c.getWidth(), c.getHeight()); |
3 | } |
4 | |
5 | static Pt calcFitSize(BufferedImage image, int w, int h) {
|
6 | int iw = image.getWidth(), ih = image.getHeight(); |
7 | double imgScale = max(doubleRatio(h, ih), doubleRatio(w, iw)); |
8 | ret pt(iround(iw*imgScale), iround(ih*imgScale)); |
9 | } |
Began life as a copy of #1019437
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1019468 |
| Snippet name: | calcFitSize - calculate size for image to fit in component or similar |
| Eternal ID of this version: | #1019468/7 |
| Text MD5: | ebe3a78507f6063752e38b38282b21c2 |
| Transpilation MD5: | 82b4e947ae140dc4febf00c4c3938df2 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-29 02:59:42 |
| Source code size: | 354 bytes / 9 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 593 / 731 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |