From 35fcf49d1cb49e3844e7cee44f34d827d8a102ce Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 22:24:08 +0200 Subject: Bug 724: Add manual unit test, incr. PNGImage verbosity. --- .../jogamp/opengl/util/texture/spi/PNGImage.java | 3 +- .../jogl/demos/es2/TextureDraw01ES2Listener.java | 13 +++-- .../jogl/util/texture/TestPNGImage00NEWT.java | 62 ++++++++++++++++++++++ .../jogl/util/texture/TestPNGImage01NEWT.java | 62 ---------------------- 4 files changed, 72 insertions(+), 68 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java (limited to 'src') diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java index b4b00e744..93d37029e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java @@ -177,7 +177,8 @@ public class PNGImage { } if(DEBUG) { System.err.println("PNGImage: "+imgInfo); - System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+", bytesPerPixel "+bytesPerPixel+ + System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+"/"+imgInfo.channels+ + ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ ", pixels "+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+"x"+dpi[1]+", glFormat 0x"+Integer.toHexString(glFormat)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 622df8695..f6b6d2873 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -56,14 +56,18 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A PMVMatrix pmvMatrix; GLUniformData pmvMatrixUniform; GLArrayDataServer interleavedVBO; - + float[] clearColor = new float[] { 1.0f, 1.0f, 1.0f, 0.4f }; public TextureDraw01ES2Listener(TextureData td) { this.textureData = td; } + + public void setClearColor(float[] clearColor) { + this.clearColor = clearColor; + } static final String shaderBasename = "texture01_xxx"; - + private void initShader(GL2ES2 gl, boolean use_program) { // Create & Compile the shader objects ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), @@ -134,7 +138,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A st.ownAttribute(interleavedVBO, true); // OpenGL Render Settings - gl.glClearColor(0, 0, 0, 1); + gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); } @@ -164,8 +168,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A gl.glViewport(0, 0, width, height); // Clear background to white - gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); - + gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); if(null != st) { pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java new file mode 100644 index 000000000..210d03afa --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java @@ -0,0 +1,62 @@ +package com.jogamp.opengl.test.junit.jogl.util.texture; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URLConnection; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.texture.spi.PNGImage; + +public class TestPNGImage00NEWT extends UITestCase { + @Test + public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { + final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); + final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); + final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); + final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); + final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); + final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; + URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); + PNGImage image1 = PNGImage.read(urlConn.getInputStream()); + System.err.println("PNGImage - Orig: "+image1); + image1.write(out1_f, true); + { + Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); + } + + final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2.write(out2_f, true); + { + Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); + } + + // flipped + final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2F.write(out2F_f, true); + + // reversed channels + final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2R.write(out2R_f, true); + + // reversed channels and flipped + final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2RF.write(out2RF_f, true); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPNGImage00NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java deleted file mode 100644 index 81f64f0ae..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -public class TestPNGImage01NEWT extends UITestCase { - @Test - public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { - final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); - final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); - final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); - final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); - final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); - final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; - URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image1 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image1); - image1.write(out1_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); - } - - final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2.write(out2_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); - } - - // flipped - final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2F.write(out2F_f, true); - - // reversed channels - final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2R.write(out2R_f, true); - - // reversed channels and flipped - final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2RF.write(out2RF_f, true); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPNGImage01NEWT.class.getName()); - } -} -- cgit v1.2.3