diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/texture')
5 files changed, 52 insertions, 35 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index 35604ba30..08f56ef27 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -43,7 +43,6 @@ import javax.media.opengl.*; import javax.media.opengl.glu.*; import javax.media.nativewindow.NativeWindowFactory; import jogamp.opengl.*; -import com.jogamp.opengl.util.texture.*; import com.jogamp.opengl.util.texture.spi.*; /** diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index f598422bf..149a2d46c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -36,10 +36,11 @@ package com.jogamp.opengl.util.texture; -import java.nio.*; +import java.nio.Buffer; -import javax.media.opengl.*; -import com.jogamp.opengl.util.*; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.GLBuffers; /** * Represents the data for an OpenGL texture. This is separated from diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index 792f80ff8..5be7f922b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2011 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,16 +40,33 @@ package com.jogamp.opengl.util.texture; -import java.io.*; -import java.net.*; -import java.nio.*; -import java.util.*; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; -import javax.media.opengl.*; -import javax.media.opengl.glu.*; import jogamp.opengl.Debug; -import com.jogamp.opengl.util.*; -import com.jogamp.opengl.util.texture.spi.*; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.texture.spi.DDSImage; +import com.jogamp.opengl.util.texture.spi.NetPbmTextureWriter; +import com.jogamp.opengl.util.texture.spi.SGIImage; +import com.jogamp.opengl.util.texture.spi.TGAImage; +import com.jogamp.opengl.util.texture.spi.TextureProvider; +import com.jogamp.opengl.util.texture.spi.TextureWriter; /** <P> Provides input and output facilities for both loading OpenGL textures from disk and streams as well as writing textures already @@ -177,7 +195,7 @@ public class TextureIO { boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(file); + fileSuffix = IOUtil.getFileSuffix(file); } return newTextureDataImpl(glp, file, 0, 0, mipmap, fileSuffix); } @@ -234,7 +252,7 @@ public class TextureIO { boolean mipmap, String fileSuffix) throws IOException { if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); + fileSuffix = IOUtil.getFileSuffix(url.getPath()); } return newTextureDataImpl(glp, url, 0, 0, mipmap, fileSuffix); } @@ -288,7 +306,7 @@ public class TextureIO { } if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(file); + fileSuffix = IOUtil.getFileSuffix(file); } return newTextureDataImpl(glp, file, internalFormat, pixelFormat, mipmap, fileSuffix); @@ -380,7 +398,7 @@ public class TextureIO { } if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); + fileSuffix = IOUtil.getFileSuffix(url.getPath()); } return newTextureDataImpl(glp, url, internalFormat, pixelFormat, mipmap, fileSuffix); @@ -437,7 +455,7 @@ public class TextureIO { public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException { GL gl = GLContext.getCurrentGL(); GLProfile glp = gl.getGLProfile(); - TextureData data = newTextureData(glp, file, mipmap, FileUtil.getFileSuffix(file)); + TextureData data = newTextureData(glp, file, mipmap, IOUtil.getFileSuffix(file)); Texture texture = newTexture(gl, data); data.flush(); return texture; @@ -494,7 +512,7 @@ public class TextureIO { */ public static Texture newTexture(URL url, boolean mipmap, String fileSuffix) throws IOException, GLException { if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); + fileSuffix = IOUtil.getFileSuffix(url.getPath()); } GL gl = GLContext.getCurrentGL(); GLProfile glp = gl.getGLProfile(); @@ -878,7 +896,7 @@ public class TextureIO { boolean mipmap, String fileSuffix) throws IOException { if (DDS.equals(fileSuffix) || - DDS.equals(FileUtil.getFileSuffix(file))) { + DDS.equals(IOUtil.getFileSuffix(file))) { DDSImage image = DDSImage.read(file); return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); } @@ -893,7 +911,7 @@ public class TextureIO { String fileSuffix) throws IOException { if (DDS.equals(fileSuffix) || DDSImage.isDDSImage(stream)) { - byte[] data = StreamUtil.readAll2Array(stream); + byte[] data = IOUtil.copyStream2ByteArray(stream); ByteBuffer buf = ByteBuffer.wrap(data); DDSImage image = DDSImage.read(buf); return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); @@ -1014,7 +1032,7 @@ public class TextureIO { internalFormat, pixelFormat, mipmap, - ((fileSuffix != null) ? fileSuffix : FileUtil.getFileSuffix(file))); + ((fileSuffix != null) ? fileSuffix : IOUtil.getFileSuffix(file))); } finally { inStream.close(); } @@ -1113,7 +1131,7 @@ public class TextureIO { static class DDSTextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { - if (DDS.equals(FileUtil.getFileSuffix(file))) { + if (DDS.equals(IOUtil.getFileSuffix(file))) { // See whether the DDS writer can handle this TextureData int pixelFormat = data.getPixelFormat(); int pixelType = data.getPixelType(); @@ -1162,7 +1180,7 @@ public class TextureIO { static class SGITextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { - String fileSuffix = FileUtil.getFileSuffix(file); + String fileSuffix = IOUtil.getFileSuffix(file); if (SGI.equals(fileSuffix) || SGI_RGB.equals(fileSuffix)) { // See whether the SGI writer can handle this TextureData @@ -1206,7 +1224,7 @@ public class TextureIO { static class TGATextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { - if (TGA.equals(FileUtil.getFileSuffix(file))) { + if (TGA.equals(IOUtil.getFileSuffix(file))) { // See whether the TGA writer can handle this TextureData int pixelFormat = data.getPixelFormat(); int pixelType = data.getPixelType(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java index 499dce7fb..ae9618490 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java @@ -40,13 +40,12 @@ package com.jogamp.opengl.util.texture.spi; import java.io.*; -import java.net.*; import java.nio.*; import javax.media.opengl.*; -import com.jogamp.opengl.util.*; + +import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.texture.*; -import com.jogamp.opengl.util.texture.spi.*; public class NetPbmTextureWriter implements TextureWriter { int magic; @@ -87,17 +86,17 @@ public class NetPbmTextureWriter implements TextureWriter { // file suffix selection if (0==magic) { - if (PPM.equals(FileUtil.getFileSuffix(file))) { + if (PPM.equals(IOUtil.getFileSuffix(file))) { magic = 6; - } else if (PAM.equals(FileUtil.getFileSuffix(file))) { + } else if (PAM.equals(IOUtil.getFileSuffix(file))) { magic = 7; } else { return false; } } - int pixelFormat = data.getPixelFormat(); - int pixelType = data.getPixelType(); + final int pixelFormat = data.getPixelFormat(); + final int pixelType = data.getPixelType(); if ((pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA) && (pixelType == GL.GL_BYTE || diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java index 405211204..89d0d20a1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java @@ -42,12 +42,12 @@ package com.jogamp.opengl.util.texture.spi.awt; import java.awt.Graphics; import java.awt.image.*; import java.io.*; -import java.net.*; import java.nio.*; import javax.imageio.*; import javax.media.opengl.*; -import com.jogamp.opengl.util.*; + +import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.awt.*; import com.jogamp.opengl.util.texture.*; import com.jogamp.opengl.util.texture.spi.*; @@ -101,7 +101,7 @@ public class IIOTextureWriter implements TextureWriter { ImageUtil.flipImageVertically(image); // Happened to notice that writing RGBA images to JPEGS is broken - if (TextureIO.JPG.equals(FileUtil.getFileSuffix(file)) && + if (TextureIO.JPG.equals(IOUtil.getFileSuffix(file)) && image.getType() == BufferedImage.TYPE_4BYTE_ABGR) { BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR); @@ -111,7 +111,7 @@ public class IIOTextureWriter implements TextureWriter { image = tmpImage; } - return ImageIO.write(image, FileUtil.getFileSuffix(file), file); + return ImageIO.write(image, IOUtil.getFileSuffix(file), file); } throw new IOException("ImageIO writer doesn't support this pixel format / type (only GL_RGB/A + bytes)"); |