1package com.jogamp.opengl.test.junit.jogl.util.texture;
4import java.io.IOException;
5import java.net.URISyntaxException;
7import java.net.URLConnection;
8import java.nio.ByteBuffer;
10import org.junit.After;
11import org.junit.Assert;
12import org.junit.Before;
15import com.jogamp.common.util.IOUtil;
16import com.jogamp.opengl.util.texture.spi.DDSImage;
17import com.jogamp.opengl.util.texture.spi.DDSImage.ImageInfo;
40 File testDDSImage01Uncompressed;
41 File testDDSImage02DXT1;
42 File testDDSImage03DXT5;
45 public void setup() throws Throwable {
46 testDDSImage01Uncompressed = initFile(
"test-64x32_uncompressed.dds");
47 testDDSImage02DXT1 = initFile(
"test-64x32_DXT1.dds");
48 testDDSImage03DXT5 = initFile(
"test-64x32_DXT5.dds");
53 testDDSImage01Uncompressed =
null;
54 testDDSImage02DXT1 =
null;
55 testDDSImage03DXT5 =
null;
58 private File initFile(
final String filename)
throws URISyntaxException {
59 final URLConnection connection = IOUtil.getResource(filename, getClass().getClassLoader(), getClass());
60 Assert.assertNotNull(connection);
61 final URL url = connection.getURL();
62 final File file =
new File(url.toURI());
63 Assert.assertTrue(file.exists());
67 private void testImpl(
final File file)
throws IOException {
68 final DDSImage ddsImage = DDSImage.read(file);
69 Assert.assertNotNull(ddsImage);
70 final int numMipMaps = ddsImage.getNumMipMaps();
71 final ByteBuffer[] mipMapArray =
new ByteBuffer[numMipMaps];
72 for (
int i=0;i<numMipMaps;i++){
73 final ImageInfo info = ddsImage.getMipMap(i);
74 mipMapArray[i] = info.getData();
76 final DDSImage newImage = DDSImage.createFromData(ddsImage.getPixelFormat(), ddsImage.getWidth(), ddsImage.getHeight(), mipMapArray);
77 Assert.assertNotNull(newImage);
82 testImpl(testDDSImage01Uncompressed);
87 testImpl(testDDSImage02DXT1);
92 testImpl(testDDSImage03DXT5);
95 public static void main(
final String[] args) {
This test uses the DDSImage class to read a dds image from file, extract the data,...
void test01_DDSImage_CreateFromData_DXT1_RGB()
void test02_DDSImage_CreateFromData_DXT5_RGB()
void test00_DDSImage_CreateFromData_Uncompressed_RGB()
static void main(final String[] args)