28package com.jogamp.opengl.test.junit.jogl.util.texture;
30import java.io.IOException;
31import java.net.MalformedURLException;
32import java.net.URLConnection;
34import com.jogamp.nativewindow.util.PixelFormat;
35import com.jogamp.nativewindow.util.PixelFormatUtil;
36import com.jogamp.nativewindow.util.PixelRectangle;
38import org.junit.Assert;
40import org.junit.FixMethodOrder;
41import org.junit.runners.MethodSorters;
43import com.jogamp.common.util.Bitstream;
44import com.jogamp.common.util.IOUtil;
45import com.jogamp.opengl.test.junit.util.UITestCase;
46import com.jogamp.opengl.util.PNGPixelRect;
53@FixMethodOrder(MethodSorters.NAME_ASCENDING)
57 final String basename =
"test-ntscN_4-01-160x90";
58 final String pathname=
"";
63 final String basename =
"test-ntscN_4-01-160x90";
64 final String pathname=
"";
69 final String basename =
"test-ntscN_4-01-160x90";
70 final String pathname=
"";
75 final String basename =
"test-ntscN_4-01-160x90";
76 final String pathname=
"";
80 private void testPNG01Impl(
final String pathname,
final String basename,
final PixelFormat srcFmt,
81 final int destMinStrideInBytes,
final boolean destIsGLOriented)
82 throws InterruptedException, IOException, MalformedURLException
84 System.err.println(
"Test01: "+pathname+basename+
".png, srcFmt "+srcFmt+
", destMinStrideInBytes "+destMinStrideInBytes+
", destIsGLOriented "+destIsGLOriented);
86 final URLConnection urlConn = IOUtil.getResource(pathname+basename+
".png", this.getClass().getClassLoader(), this.getClass());
89 System.err.println(
"PNGPixelRect - Orig: "+image1);
94 for(
int i=0; i<formats.length; i++) {
95 final PixelFormat destFmt = formats[i];
96 System.err.println(
"CONVERT["+i+
"]: "+srcFmt+
" -> "+destFmt);
97 final PixelRectangle imageConv1 = PixelFormatUtil.convert(image1, destFmt, destMinStrideInBytes, destIsGLOriented,
false );
98 System.err.println(
"PNGPixelRect - Conv1: "+imageConv1);
99 System.err.printf(
"Conv1 Data: %s%n", Bitstream.toHexBinString(
true, imageConv1.getPixels(), 0, imageConv1.getPixelformat().comp.bytesPerPixel()));
100 TestPixelFormatUtil00NEWT.dumpComponents(imageConv1, 0, 0, 3, 3);
102 System.err.println(
"PNGPixelRect - Conv2: "+imageConv2);
103 System.err.printf(
"Conv2 Data: %s%n", Bitstream.toHexBinString(
true, imageConv2.getPixels(), 0, imageConv2.getPixelformat().comp.bytesPerPixel()));
104 TestPixelFormatUtil00NEWT.dumpComponents(imageConv2, 0, 0, 3, 3);
105 Assert.assertEquals(image1.
getPixels(), imageConv2.getPixels());
109 public static void main(
final String args[]) {
int getStride()
Returns stride in byte-size, i.e.
ByteBuffer getPixels()
Returns the pixels.
final boolean isGLOriented
PixelFormat getPixelformat()
Returns the PixelFormat.
Testing PixelFormatUtil's Conversion using synthetic test data including strides, endian-order and al...
Testing PixelFormatUtil's Conversion using PNG test data including strides, endian-order and PixelFor...
void testPNGRead14_fromARGB8888()
void testPNGRead11_fromRGBA8888()
static void main(final String args[])
void testPNGRead12_fromABGR8888()
void testPNGRead13_fromBGRA8888()
static PNGPixelRect read(final InputStream in, final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, final boolean destIsGLOriented)
Reads a PNG image from the specified InputStream.