summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-07 15:31:06 +0200
committerSven Gothel <[email protected]>2012-04-07 15:31:06 +0200
commit073c9744fa4a8982850a0f8d61275f8782497bbb (patch)
tree19257f42cfdf488fec38a3698e95233dfd0c35f0 /src/test/com
parent40830196070013432bc5f453eb31cfe4c64e0510 (diff)
TextureIO: Add PNG TextureProvider and TextureWriter for RGB[A]/BGR[A] - incl. unit tests; Test/Demos: Use PNG snapshots.
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java3
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java36
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java41
6 files changed, 83 insertions, 5 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
index 668cdc607..a3182a30f 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
@@ -193,7 +193,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
PrintWriter pw = new PrintWriter(sw);
pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize[0], objName);
- final String filename = dir + tech + sw +".tga";
+ final String filename = dir + tech + sw +".png";
if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
screenshot.write(new File(filename));
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
index d9d2dd95a..d0093ad0c 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
@@ -179,7 +179,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
PrintWriter pw = new PrintWriter(sw);
pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), 0, objName);
- final String filename = dir + tech + sw +".tga";
+ final String filename = dir + tech + sw +".png";
if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
screenshot.write(new File(filename));
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
index b829c8deb..9506d00e5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
@@ -31,7 +31,6 @@ package com.jogamp.opengl.test.junit.jogl.offscreen;
import java.io.IOException;
import javax.media.opengl.*;
-import com.jogamp.opengl.util.texture.TextureIO;
import java.io.File;
public class ReadBuffer2File extends ReadBufferBase {
@@ -51,7 +50,7 @@ public class ReadBuffer2File extends ReadBufferBase {
return;
}
- File file = File.createTempFile("shot" + shotNum + "-", ".ppm");
+ File file = File.createTempFile("shot" + shotNum + "-", ".png");
readBufferUtil.write(file);
System.out.println("Wrote: " + file.getAbsolutePath() + ", ...");
shotNum++;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java
index 4bae83e74..ab8e54246 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java
@@ -68,7 +68,7 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
}
@Test
- public void testWriteTGAAndPAM() throws InterruptedException {
+ public void testWritePNG_TGA_PAM() throws InterruptedException {
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Shared Gears NEWT Test");
@@ -79,8 +79,10 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase {
public void dispose(GLAutoDrawable drawable) {}
public void display(GLAutoDrawable drawable) {
// snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".ppm");
+ snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".png");
snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".tga");
snapshot(drawable, true, true, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".pam");
+ snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".png");
snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".tga");
snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".pam");
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java
index 0c48a10e5..79ae31612 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java
@@ -104,6 +104,42 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase {
glWindow.destroy();
}
+ @Test
+ public void testWritePNGWithResize() throws InterruptedException {
+ final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
+ GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle("Shared Gears NEWT Test");
+ glWindow.setSize(width, height);
+ glWindow.addGLEventListener(new GearsES2(1));
+ glWindow.addGLEventListener(new GLEventListener() {
+ int i=0;
+ public void init(GLAutoDrawable drawable) {}
+ public void dispose(GLAutoDrawable drawable) {}
+ public void display(GLAutoDrawable drawable) {
+ StringWriter filename = new StringWriter();
+ {
+ PrintWriter pw = new PrintWriter(filename);
+ pw.printf("%s-rgba-%s-%03dx%03d-n%03d.png",
+ getSimpleTestName("."), drawable.getGLProfile().getName(),
+ drawable.getWidth(), drawable.getHeight(), i++);
+ }
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename.toString()));
+ }
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y,
+ int width, int height) { }
+ });
+ glWindow.setVisible(true);
+ Thread.sleep(60);
+ glWindow.setSize(300, 300);
+ Thread.sleep(60);
+ glWindow.setSize(400, 400);
+ Thread.sleep(60);
+ glWindow.destroy();
+ }
+
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestGLReadBufferUtilTextureIOWrite02NEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
new file mode 100644
index 000000000..5a0c18de7
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
@@ -0,0 +1,41 @@
+package com.jogamp.opengl.test.junit.jogl.util;
+
+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 String url_s="jogl/util/data/av/test-ntsc01-160x90.png";
+ URLConnection urlConn = IOUtil.getResource(url_s, PNGImage.class.getClassLoader());
+ PNGImage image0 = PNGImage.read(urlConn.getInputStream());
+ System.err.println("PNGImage - Orig: "+image0);
+ image0.write(out1_f, true);
+ {
+ Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData());
+ }
+
+ final PNGImage image1 = PNGImage.createFromData(image0.getWidth(), image0.getHeight(),
+ image0.getDpi()[0], image0.getDpi()[1],
+ image0.getBytesPerPixel(), false, image0.getData());
+ image1.write(out2_f, true);
+ {
+ Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData());
+ }
+ }
+
+ public static void main(String args[]) {
+ org.junit.runner.JUnitCore.main(TestPNGImage01NEWT.class.getName());
+ }
+}