< prev index next >
test/jdk/java/awt/dnd/ImageTransferTest/ImageTransferTest.java
Print this page
*** 22,32 ****
*/
/*
* @test
* @key headful
! * @bug 4397404 4720930 8197926
* @summary tests that images of all supported native image formats are
* transferred properly
* @library /test/lib
* @library ../../regtesthelpers/process/
* @build jdk.test.lib.Platform ProcessResults ProcessCommunicator
--- 22,32 ----
*/
/*
* @test
* @key headful
! * @bug 4397404 4720930 8197926 8176556
* @summary tests that images of all supported native image formats are
* transferred properly
* @library /test/lib
* @library ../../regtesthelpers/process/
* @build jdk.test.lib.Platform ProcessResults ProcessCommunicator
*** 147,173 ****
private static Image createImage() {
int w = 100;
int h = 100;
int[] pix = new int[w * h];
int index = 0;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int red = 127;
int green = 127;
int blue = y > h / 2 ? 127 : 0;
- int alpha = 255;
if (x < w / 4 && y < h / 4) {
- alpha = 0;
red = 0;
}
! pix[index++] =
! (alpha << 24) | (red << 16) | (green << 8) | blue;
}
}
! return Toolkit.getDefaultToolkit().
! createImage(new MemoryImageSource(w, h, pix, 0, w));
}
static String[] retrieveFormatsToTest() {
SystemFlavorMap sfm =
--- 147,173 ----
private static Image createImage() {
int w = 100;
int h = 100;
int[] pix = new int[w * h];
+ BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
int index = 0;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int red = 127;
int green = 127;
int blue = y > h / 2 ? 127 : 0;
if (x < w / 4 && y < h / 4) {
red = 0;
}
! pix[index] =
! (red << 16) | (green << 8) | blue;
! img.setRGB(x, y, pix[index]);
! index++;
}
}
! return (Image)img;
}
static String[] retrieveFormatsToTest() {
SystemFlavorMap sfm =
*** 202,241 ****
if (ib1.length != ib2.length) {
return false;
}
- if (formats[fi].equals("PNG") ||
- formats[fi].equals("image/png") ||
- formats[fi].equals("image/x-png")) {
- // check alpha as well
for (int i = 0; i < ib1.length; i++) {
if (ib1[i] != ib2[i]) {
System.err.println("different pixels: " +
Integer.toHexString(ib1[i]) + " " +
Integer.toHexString(ib2[i]));
return false;
}
}
- } else {
- for (int i = 0; i < ib1.length; i++) {
- if ((ib1[i] & 0x00FFFFFF) != (ib2[i] & 0x00FFFFFF)) {
- System.err.println("different pixels: " +
- Integer.toHexString(ib1[i]) + " " +
- Integer.toHexString(ib2[i]));
- return false;
- }
- }
- }
return true;
}
private static int[] getImageData(Image image) {
int width = image.getWidth(null);
int height = image.getHeight(null);
BufferedImage bimage =
! new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bimage.createGraphics();
try {
g2d.drawImage(image, 0, 0, width, height, null);
} finally {
g2d.dispose();
--- 202,227 ----
if (ib1.length != ib2.length) {
return false;
}
for (int i = 0; i < ib1.length; i++) {
if (ib1[i] != ib2[i]) {
System.err.println("different pixels: " +
Integer.toHexString(ib1[i]) + " " +
Integer.toHexString(ib2[i]));
return false;
}
}
return true;
}
private static int[] getImageData(Image image) {
int width = image.getWidth(null);
int height = image.getHeight(null);
BufferedImage bimage =
! new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bimage.createGraphics();
try {
g2d.drawImage(image, 0, 0, width, height, null);
} finally {
g2d.dispose();
< prev index next >