use of java.awt.image in project jdk8u_jdk by JetBrains.
the class MultiResolutionToolkitImageTest method testToolkitMultiResolutionImageLoad.
static void testToolkitMultiResolutionImageLoad() throws Exception {
File imageFile = new File(IMAGE_NAME_1X);
String fileName = imageFile.getAbsolutePath();
Image image = Toolkit.getDefaultToolkit().getImage(fileName);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.prepareImage(image, -1, -1, new LoadImageObserver());
final long time = WAIT_TIME + System.currentTimeMillis();
while ((!isImageLoaded || !isRVObserverCalled) && System.currentTimeMillis() < time) {
Thread.sleep(50);
}
if (!isImageLoaded) {
throw new RuntimeException("Image is not loaded!");
}
if (!isRVObserverCalled) {
throw new RuntimeException("Resolution Variant observer is not called!");
}
}
use of java.awt.image in project jdk8u_jdk by JetBrains.
the class MultiResolutionImageTest method testToolkitMultiResolutionImage.
static void testToolkitMultiResolutionImage() throws Exception {
generateImages();
File imageFile = new File(IMAGE_NAME_1X);
String fileName = imageFile.getAbsolutePath();
URL url = imageFile.toURI().toURL();
testToolkitMultiResolutionImageChache(fileName, url);
Image image = Toolkit.getDefaultToolkit().getImage(fileName);
testToolkitImageObserver(image);
testToolkitMultiResolutionImage(image, false);
testToolkitMultiResolutionImage(image, true);
image = Toolkit.getDefaultToolkit().getImage(url);
testToolkitImageObserver(image);
testToolkitMultiResolutionImage(image, false);
testToolkitMultiResolutionImage(image, true);
}
use of java.awt.image in project jdk8u_jdk by JetBrains.
the class MultiResolutionImageTest method testToolkitMultiResolutionImageLoad.
static void testToolkitMultiResolutionImageLoad() throws Exception {
generateImages();
File imageFile = new File(IMAGE_NAME_1X);
String fileName = imageFile.getAbsolutePath();
Image image = Toolkit.getDefaultToolkit().getImage(fileName);
testToolkitMultiResolutionImageLoad(image);
}
use of java.awt.image in project jdk8u_jdk by JetBrains.
the class MultiResolutionCachedImageTest method main.
public static void main(String[] args) {
Image image = new TestMultiResolutionCachedImage(100);
image.getWidth(null);
image.getHeight(null);
image.getProperty("comment", null);
int scaledSize = 50;
Image scaledImage = image.getScaledInstance(scaledSize, scaledSize, Image.SCALE_SMOOTH);
if (!(scaledImage instanceof BufferedImage)) {
throw new RuntimeException("Wrong scaled image!");
}
BufferedImage buffScaledImage = (BufferedImage) scaledImage;
if (buffScaledImage.getWidth() != scaledSize || buffScaledImage.getHeight() != scaledSize) {
throw new RuntimeException("Wrong scaled image!");
}
if (buffScaledImage.getRGB(scaledSize / 2, scaledSize / 2) != TEST_COLOR.getRGB()) {
throw new RuntimeException("Wrong scaled image!");
}
}
use of java.awt.image in project jdk8u_jdk by JetBrains.
the class MultiResolutionImageObserverTest method main.
public static void main(String[] args) throws Exception {
generateImages();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X);
LoadImageObserver sizeObserver = new LoadImageObserver(WIDTH | HEIGHT);
toolkit.prepareImage(image, -1, -1, sizeObserver);
waitForImageLoading(sizeObserver, "The first observer is not called");
LoadImageObserver bitsObserver = new LoadImageObserver(SOMEBITS | FRAMEBITS | ALLBITS);
BufferedImage buffImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) buffImage.createGraphics();
g2d.scale(2, 2);
g2d.drawImage(image, 0, 0, bitsObserver);
waitForImageLoading(bitsObserver, "The second observer is not called!");
g2d.dispose();
}
Aggregations