/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6557713
* @summary Test verifies that PNG image writer correctly handles indexed images with
* various types of transparency.
*
* Test for 4bpp OPAQUE image
* @run main GrayPngTest 4 1 3
*
* Test for 4bpp BITMASK image with transparent pixel 3
* @run main GrayPngTest 4 2 3
*
* Test for 4bpp TRANSLUCENT image
* @run main GrayPngTest 4 3 3
*
* Test for 8bpp OPAQUE image
* @run main GrayPngTest 8 1 127
*
* Test for 8bpp BITMASK image with transparent pixel 127
* @run main GrayPngTest 8 2 127
*
* Test for 8bpp TRANSLUCENT image
* @run main GrayPngTest 8 3 127
*
*/
public class GrayPngTest {
/*
* Expected argiments:
* args[0] - bits per pixel. Supported range: [1, 8]
* args[1] - transparency type. Should be one form
* java.awt.Transparency type constants.
* args[2] - transparent pixel for BITMASK transparency type,
* otherwise is ignored.
*/
int bpp = 4;
int trans_pixel = 3;
try {
} catch (NumberFormatException e) {
} catch (ArrayIndexOutOfBoundsException e) {
}
}
switch(trans_type) {
case Transparency.OPAQUE:
break;
case Transparency.BITMASK:
break;
case Transparency.TRANSLUCENT:
break;
default:
}
int w = 256 * 2;
int h = 200;
for (int i = 0; i < numColors; i ++) {
}
// horizontal line with transparent color
int[] samples = new int[w * 10];
// create index color model
}
private int bpp;
private int numColors;
private int dx;
private byte[] r;
private byte[] g;
private byte[] b;
private byte[] a;
}
// create palette
r = new byte[numColors];
g = new byte[numColors];
b = new byte[numColors];
for (int i = 0; i < numColors; i ++) {
byte l = (byte)(i * dc);
r[i] = l; g[i] = l; b[i] = l;
}
}
for (int i = 0; i < numColors; i++) {
}
}
trans_type + "tt_" +
throw new RuntimeException("Writing failed!");
};
try {
} catch (Exception e) {
throw new RuntimeException("Test FAILED.", e);
}
checkImages();
}
private void checkImages() {
for (int i = 0; i < numColors; i++) {
// here we check transparency only due to possible colors space
// differences (sRGB in indexed source and Gray in gray+alpha destination)
throw new RuntimeException("Test FAILED. Color difference detected: " +
}
}
}
}