| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.bulenkov.iconloader; |
| 18 |
|
| 19 |
import java.awt.*; |
| 20 |
import java.awt.image.BufferedImage; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public class JBHiDPIScaledImage extends BufferedImage { |
| 26 |
private final Image myImage; |
| 27 |
|
| 28 |
public JBHiDPIScaledImage(int width, int height, int type) { |
| 29 |
this(null, 2 * width, 2 * height, type); |
| 30 |
} |
| 31 |
|
| 32 |
public JBHiDPIScaledImage(Image image, int width, int height, int type) { |
| 33 |
super(width, height, type); |
| 34 |
myImage = image; |
| 35 |
} |
| 36 |
|
| 37 |
public Image getDelegate() { |
| 38 |
return myImage; |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public Graphics2D createGraphics() { |
| 43 |
final Graphics2D g = super.createGraphics(); |
| 44 |
|
| 45 |
if (myImage == null) { |
| 46 |
return new HiDPIScaledGraphics(g, this); |
| 47 |
} |
| 48 |
|
| 49 |
return g; |
| 50 |
} |
| 51 |
} |