1 | import java.awt.geom.*; |
2 | |
3 | static void paintFitBackground_smooth(Component c, Graphics _g, BufferedImage image) {
|
4 | Graphics2D g = cast _g; |
5 | RenderingHints hints = g.getRenderingHints(); |
6 | antiAliasOn(g); |
7 | int w = c.getWidth(), h = c.getHeight(); |
8 | int iw = image.getWidth(), ih = image.getHeight(); |
9 | g.setColor(c.getBackground()); |
10 | g.fillRect(0, 0, w, h); |
11 | double imgScale = max(doubleRatio(h, ih), doubleRatio(w, iw)); |
12 | double y1 = h-ih*imgScale; |
13 | g.drawImage(scaleImage(image, imgScale), iround((w-iw*imgScale)/2), iround((h-ih*imgScale)/2), null); |
14 | g.setRenderingHints(hints); |
15 | } |
Began life as a copy of #1016579
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: | #1019437 |
| Snippet name: | paintFitBackground_smooth - fit so whole screen is filled + smoothing |
| Eternal ID of this version: | #1019437/5 |
| Text MD5: | 84a90ed49d4c2fccb2aa7efb56e790a9 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-11-06 19:37:46 |
| Source code size: | 602 bytes / 15 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 572 / 661 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |