author | ohair |
Mon, 04 Jan 2010 15:56:42 -0800 | |
changeset 4663 | dfea6ffdb0dc |
parent 2385 | bfc8967dfe97 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2385
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
1 |
/* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
4 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
8 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
13 |
* accompanied this code). |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
14 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
18 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
21 |
* have any questions. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
22 |
*/ |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
23 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
24 |
/** |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
25 |
* @test |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
26 |
* @bug 6800846 |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
27 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
28 |
* @summary Test verifes that images with short palette are rendered |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
29 |
* withourt artifacts. |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
30 |
* |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
31 |
* @run main DrawByteBinary |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
32 |
*/ |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
33 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
34 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
35 |
import java.awt.*; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
36 |
import java.awt.color.*; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
37 |
import java.awt.image.*; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
38 |
import static java.awt.image.BufferedImage.*; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
39 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
40 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
41 |
public class DrawByteBinary { |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
42 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
43 |
public static void main(String args[]) { |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
44 |
int w = 100, h = 30; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
45 |
int x = 10; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
46 |
byte[] arr = {(byte)0xff, (byte)0x0, (byte)0x00}; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
47 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
48 |
IndexColorModel newCM = new IndexColorModel(1, 2, arr, arr, arr); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
49 |
BufferedImage orig = new BufferedImage(w, h, TYPE_BYTE_BINARY, newCM); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
50 |
Graphics2D g2d = orig.createGraphics(); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
51 |
g2d.setColor(Color.white); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
52 |
g2d.fillRect(0, 0, w, h); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
53 |
g2d.setColor(Color.black); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
54 |
g2d.drawLine(x, 0, x, h); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
55 |
g2d.dispose(); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
56 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
57 |
IndexColorModel origCM = (IndexColorModel)orig.getColorModel(); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
58 |
BufferedImage test = new BufferedImage(w, h, TYPE_BYTE_BINARY,origCM); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
59 |
g2d = test.createGraphics(); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
60 |
g2d.drawImage(orig, 0, 0, null); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
61 |
g2d.dispose(); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
62 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
63 |
int y = h / 2; |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
64 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
65 |
// we expect white color outside the line |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
66 |
if (test.getRGB(x - 1, y) != 0xffffffff) { |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
67 |
throw new RuntimeException("Invalid color outside the line."); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
68 |
} |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
69 |
|
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
70 |
// we expect black color on the line |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
71 |
if (test.getRGB(x, y) != 0xff000000) { |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
72 |
throw new RuntimeException("Invalid color on the line."); |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
73 |
} |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
74 |
} |
bfc8967dfe97
6800846: REGRESSION: Printing quality degraded with Java 6 compared to 5.0
bae
parents:
diff
changeset
|
75 |
} |