aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/texture/spi
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 16:21:36 +0200
committerSven Gothel <[email protected]>2014-07-03 16:21:36 +0200
commit556d92b63555a085b25e32b1cd55afce24edd07a (patch)
tree6be2b02c62a77d5aba81ffbe34c46960608be163 /src/jogl/classes/com/jogamp/opengl/util/texture/spi
parenta90f4a51dffec3247278e3c683ed4462b1dd9ab5 (diff)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/texture/spi')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java143
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java48
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java30
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java22
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java128
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java76
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java36
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java26
9 files changed, 265 insertions, 264 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java
index 7311f20b3..20fc92819 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java
@@ -52,6 +52,7 @@ import java.nio.channels.FileChannel;
import javax.media.opengl.GL;
+import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.GLBuffers;
@@ -67,13 +68,13 @@ public class DDSImage {
that information in another way. */
public static class ImageInfo {
- private ByteBuffer data;
- private int width;
- private int height;
- private boolean isCompressed;
- private int compressionFormat;
+ private final ByteBuffer data;
+ private final int width;
+ private final int height;
+ private final boolean isCompressed;
+ private final int compressionFormat;
- public ImageInfo(ByteBuffer data, int width, int height, boolean compressed, int compressionFormat) {
+ public ImageInfo(final ByteBuffer data, final int width, final int height, final boolean compressed, final int compressionFormat) {
this.data = data; this.width = width; this.height = height;
this.isCompressed = compressed; this.compressionFormat = compressionFormat;
}
@@ -163,7 +164,7 @@ public class DDSImage {
@return DDS image object
@throws java.io.IOException if an I/O exception occurred
*/
- public static DDSImage read(String filename) throws IOException {
+ public static DDSImage read(final String filename) throws IOException {
return read(new File(filename));
}
@@ -174,8 +175,8 @@ public class DDSImage {
@return DDS image object
@throws java.io.IOException if an I/O exception occurred
*/
- public static DDSImage read(File file) throws IOException {
- DDSImage image = new DDSImage();
+ public static DDSImage read(final File file) throws IOException {
+ final DDSImage image = new DDSImage();
image.readFromFile(file);
return image;
}
@@ -187,8 +188,8 @@ public class DDSImage {
@return DDS image object
@throws java.io.IOException if an I/O exception occurred
*/
- public static DDSImage read(ByteBuffer buf) throws IOException {
- DDSImage image = new DDSImage();
+ public static DDSImage read(final ByteBuffer buf) throws IOException {
+ final DDSImage image = new DDSImage();
image.readFromBuffer(buf);
return image;
}
@@ -207,7 +208,7 @@ public class DDSImage {
fis = null;
}
buf = null;
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@@ -228,11 +229,11 @@ public class DDSImage {
* specified arguments
* @return DDS image object
*/
- public static DDSImage createFromData(int d3dFormat,
- int width,
- int height,
- ByteBuffer[] mipmapData) throws IllegalArgumentException {
- DDSImage image = new DDSImage();
+ public static DDSImage createFromData(final int d3dFormat,
+ final int width,
+ final int height,
+ final ByteBuffer[] mipmapData) throws IllegalArgumentException {
+ final DDSImage image = new DDSImage();
image.initFromData(d3dFormat, width, height, mipmapData);
return image;
}
@@ -256,7 +257,7 @@ public class DDSImage {
in.mark(4);
int magic = 0;
for (int i = 0; i < 4; i++) {
- int tmp = in.read();
+ final int tmp = in.read();
if (tmp < 0) {
in.reset();
return false;
@@ -272,7 +273,7 @@ public class DDSImage {
* @param filename File name to write to
* @throws java.io.IOException if an I/O exception occurred
*/
- public void write(String filename) throws IOException {
+ public void write(final String filename) throws IOException {
write(new File(filename));
}
@@ -281,12 +282,12 @@ public class DDSImage {
* @param file File object to write to
* @throws java.io.IOException if an I/O exception occurred
*/
- public void write(File file) throws IOException {
- FileOutputStream stream = IOUtil.getFileOutputStream(file, true);
- FileChannel chan = stream.getChannel();
+ public void write(final File file) throws IOException {
+ final FileOutputStream stream = IOUtil.getFileOutputStream(file, true);
+ final FileChannel chan = stream.getChannel();
// Create ByteBuffer for header in case the start of our
// ByteBuffer isn't actually memory-mapped
- ByteBuffer hdr = ByteBuffer.allocate(Header.writtenSize());
+ final ByteBuffer hdr = ByteBuffer.allocate(Header.writtenSize());
hdr.order(ByteOrder.LITTLE_ENDIAN);
header.write(hdr);
hdr.rewind();
@@ -302,12 +303,12 @@ public class DDSImage {
* @param flag DDSD_* flags set to test
* @return true if flag present or false otherwise
*/
- public boolean isSurfaceDescFlagSet(int flag) {
+ public boolean isSurfaceDescFlagSet(final int flag) {
return ((header.flags & flag) != 0);
}
/** Test for presence/absence of pixel format flags (DDPF_*) */
- public boolean isPixelFormatFlagSet(int flag) {
+ public boolean isPixelFormatFlagSet(final int flag) {
return ((header.pfFlags & flag) != 0);
}
@@ -357,7 +358,7 @@ public class DDSImage {
* @param side Side to test
* @return true if side present or false otherwise
*/
- public boolean isCubemapSidePresent(int side) {
+ public boolean isCubemapSidePresent(final int side) {
return isCubemap() && (header.ddsCaps2 & side) != 0;
}
@@ -402,7 +403,7 @@ public class DDSImage {
* @param map Mipmap index
* @return Image object
*/
- public ImageInfo getMipMap(int map) {
+ public ImageInfo getMipMap(final int map) {
return getMipMap( 0, map );
}
@@ -412,7 +413,7 @@ public class DDSImage {
* @param map Mipmap index
* @return Image object
*/
- public ImageInfo getMipMap(int side, int map) {
+ public ImageInfo getMipMap(final int side, final int map) {
if (!isCubemap() && (side != 0)) {
throw new RuntimeException( "Illegal side for 2D texture: " + side );
}
@@ -434,7 +435,7 @@ public class DDSImage {
}
buf.limit(seek + mipMapSizeInBytes(map));
buf.position(seek);
- ByteBuffer next = buf.slice();
+ final ByteBuffer next = buf.slice();
buf.position(0);
buf.limit(buf.capacity());
return new ImageInfo(next, mipMapWidth(map), mipMapHeight(map), isCompressed(), getCompressionFormat());
@@ -454,12 +455,12 @@ public class DDSImage {
* @param side Cubemap side or 0 for 2D texture
* @return Mipmap image objects set
*/
- public ImageInfo[] getAllMipMaps( int side ) {
+ public ImageInfo[] getAllMipMaps( final int side ) {
int numLevels = getNumMipMaps();
if (numLevels == 0) {
numLevels = 1;
}
- ImageInfo[] result = new ImageInfo[numLevels];
+ final ImageInfo[] result = new ImageInfo[numLevels];
for (int i = 0; i < numLevels; i++) {
result[i] = getMipMap(side, i);
}
@@ -472,9 +473,9 @@ public class DDSImage {
@return String format code
*/
public static String getCompressionFormatName(int compressionFormat) {
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
for (int i = 0; i < 4; i++) {
- char c = (char) (compressionFormat & 0xFF);
+ final char c = (char) (compressionFormat & 0xFF);
buf.append(c);
compressionFormat = compressionFormat >> 8;
}
@@ -491,9 +492,9 @@ public class DDSImage {
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, or
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT.
*/
- public static ByteBuffer allocateBlankBuffer(int width,
- int height,
- int openGLInternalFormat) {
+ public static ByteBuffer allocateBlankBuffer(final int width,
+ final int height,
+ final int openGLInternalFormat) {
int size = width * height;
switch (openGLInternalFormat) {
case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
@@ -511,15 +512,15 @@ public class DDSImage {
}
if (size == 0)
size = 1;
- return GLBuffers.newDirectByteBuffer(size);
+ return Buffers.newDirectByteBuffer(size);
}
public void debugPrint() {
- PrintStream tty = System.err;
+ final PrintStream tty = System.err;
tty.println("Compressed texture: " + isCompressed());
if (isCompressed()) {
- int fmt = getCompressionFormat();
- String name = getCompressionFormatName(fmt);
+ final int fmt = getCompressionFormat();
+ final String name = getCompressionFormatName(fmt);
tty.println("Compression format: 0x" + Integer.toHexString(fmt) + " (" + name + ")");
}
tty.println("Width: " + header.width + " Height: " + header.height);
@@ -567,7 +568,7 @@ public class DDSImage {
tty.println("Raw pixel format flags: 0x" + Integer.toHexString(header.pfFlags));
tty.println("Depth: " + getDepth());
tty.println("Number of mip maps: " + getNumMipMaps());
- int fmt = getPixelFormat();
+ final int fmt = getPixelFormat();
tty.print("Pixel format: ");
switch (fmt) {
case D3DFMT_R8G8B8: tty.println("D3DFMT_R8G8B8"); break;
@@ -629,8 +630,8 @@ public class DDSImage {
int ddsCapsReserved2;
int textureStage; // stage in multitexture cascade
- void read(ByteBuffer buf) throws IOException {
- int magic = buf.getInt();
+ void read(final ByteBuffer buf) throws IOException {
+ final int magic = buf.getInt();
if (magic != MAGIC) {
throw new IOException("Incorrect magic number 0x" +
Integer.toHexString(magic) +
@@ -671,7 +672,7 @@ public class DDSImage {
}
// buf must be in little-endian byte order
- void write(ByteBuffer buf) {
+ void write(final ByteBuffer buf) {
buf.putInt(MAGIC);
buf.putInt(size);
buf.putInt(flags);
@@ -722,15 +723,15 @@ public class DDSImage {
private DDSImage() {
}
- private void readFromFile(File file) throws IOException {
+ private void readFromFile(final File file) throws IOException {
fis = new FileInputStream(file);
chan = fis.getChannel();
- ByteBuffer buf = chan.map(FileChannel.MapMode.READ_ONLY,
+ final ByteBuffer buf = chan.map(FileChannel.MapMode.READ_ONLY,
0, (int) file.length());
readFromBuffer(buf);
}
- private void readFromBuffer(ByteBuffer buf) throws IOException {
+ private void readFromBuffer(final ByteBuffer buf) throws IOException {
this.buf = buf;
buf.order(ByteOrder.LITTLE_ENDIAN);
header = new Header();
@@ -738,10 +739,10 @@ public class DDSImage {
fixupHeader();
}
- private void initFromData(int d3dFormat,
- int width,
- int height,
- ByteBuffer[] mipmapData) throws IllegalArgumentException {
+ private void initFromData(final int d3dFormat,
+ final int width,
+ final int height,
+ final ByteBuffer[] mipmapData) throws IllegalArgumentException {
// Check size of mipmap data compared against format, width and
// height
int topmostMipmapSize = width * height;
@@ -784,7 +785,7 @@ public class DDSImage {
// OK, create one large ByteBuffer to hold all of the mipmap data
totalSize += Header.writtenSize();
- ByteBuffer buf = ByteBuffer.allocate(totalSize);
+ final ByteBuffer buf = ByteBuffer.allocate(totalSize);
buf.position(Header.writtenSize());
for (int i = 0; i < mipmapData.length; i++) {
buf.put(mipmapData[i]);
@@ -845,10 +846,10 @@ public class DDSImage {
}
}
- private static int computeCompressedBlockSize(int width,
- int height,
- int depth,
- int compressionFormat) {
+ private static int computeCompressedBlockSize(final int width,
+ final int height,
+ final int depth,
+ final int compressionFormat) {
int blockSize = ((width + 3)/4) * ((height + 3)/4) * ((depth + 3)/4);
switch (compressionFormat) {
case D3DFMT_DXT1: blockSize *= 8; break;
@@ -857,10 +858,10 @@ public class DDSImage {
return blockSize;
}
- private static int computeBlockSize(int width,
- int height,
- int depth,
- int pixelFormat) {
+ private static int computeBlockSize(final int width,
+ final int height,
+ final int depth,
+ final int pixelFormat) {
int blocksize;
switch (pixelFormat) {
case D3DFMT_R8G8B8:
@@ -883,7 +884,7 @@ public class DDSImage {
return blocksize;
}
- private int mipMapWidth(int map) {
+ private int mipMapWidth(final int map) {
int width = getWidth();
for (int i = 0; i < map; i++) {
width >>= 1;
@@ -891,7 +892,7 @@ public class DDSImage {
return Math.max(width, 1);
}
- private int mipMapHeight(int map) {
+ private int mipMapHeight(final int map) {
int height = getHeight();
for (int i = 0; i < map; i++) {
height >>= 1;
@@ -899,11 +900,11 @@ public class DDSImage {
return Math.max(height, 1);
}
- private int mipMapSizeInBytes(int map) {
- int width = mipMapWidth(map);
- int height = mipMapHeight(map);
+ private int mipMapSizeInBytes(final int map) {
+ final int width = mipMapWidth(map);
+ final int height = mipMapHeight(map);
if (isCompressed()) {
- int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16);
+ final int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16);
return ((width+3)/4)*((height+3)/4)*blockSize;
} else {
return width * height * (getDepth() / 8);
@@ -924,8 +925,8 @@ public class DDSImage {
return size;
}
- private int sideShiftInBytes(int side) {
- int[] sides = {
+ private int sideShiftInBytes(final int side) {
+ final int[] sides = {
DDSCAPS2_CUBEMAP_POSITIVEX,
DDSCAPS2_CUBEMAP_NEGATIVEX,
DDSCAPS2_CUBEMAP_POSITIVEY,
@@ -935,9 +936,9 @@ public class DDSImage {
};
int shift = 0;
- int sideSize = sideSizeInBytes();
+ final int sideSize = sideSizeInBytes();
for (int i = 0; i < sides.length; i++) {
- int temp = sides[i];
+ final int temp = sides[i];
if ((temp & side) != 0) {
return shift;
}
@@ -948,7 +949,7 @@ public class DDSImage {
throw new RuntimeException("Illegal side: " + side);
}
- private boolean printIfRecognized(PrintStream tty, int flags, int flag, String what) {
+ private boolean printIfRecognized(final PrintStream tty, final int flags, final int flag, final String what) {
if ((flags & flag) != 0) {
tty.println(what);
return true;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java
index 2081788ba..66a486f9b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java
@@ -51,12 +51,12 @@ public class JPEGImage {
* @return
* @throws IOException
*/
- public static JPEGImage read(InputStream in, ColorSpace cs) throws IOException {
+ public static JPEGImage read(final InputStream in, final ColorSpace cs) throws IOException {
return new JPEGImage(in, cs);
}
/** Reads a JPEG image from the specified InputStream, using the {@link ColorSpace#RGB}. */
- public static JPEGImage read(InputStream in) throws IOException {
+ public static JPEGImage read(final InputStream in) throws IOException {
return new JPEGImage(in, ColorSpace.RGB);
}
@@ -68,7 +68,7 @@ public class JPEGImage {
final ColorSpace storageCS;
ByteBuffer data = null;
- JPEGColorSink(ColorSpace storageCM) {
+ JPEGColorSink(final ColorSpace storageCM) {
this.storageCS = storageCM;
switch(storageCS) {
case RGB:
@@ -81,7 +81,7 @@ public class JPEGImage {
}
@Override
- public final ColorSpace allocate(int width, int height, ColorSpace sourceCM, int sourceComponents) throws RuntimeException {
+ public final ColorSpace allocate(final int width, final int height, final ColorSpace sourceCM, final int sourceComponents) throws RuntimeException {
this.width = width;
this.height = height;
this.sourceComponents = sourceComponents;
@@ -91,7 +91,7 @@ public class JPEGImage {
}
@Override
- public final void storeRGB(int x, int y, byte r, byte g, byte b) {
+ public final void storeRGB(final int x, final int y, final byte r, final byte g, final byte b) {
int i = ( ( height - y - 1 ) * width + x ) * storageComponents;
data.put(i++, r);
data.put(i++, g);
@@ -100,12 +100,12 @@ public class JPEGImage {
}
@Override
- public final void store2(int x, int y, byte c1, byte c2) {
+ public final void store2(final int x, final int y, final byte c1, final byte c2) {
throw new RuntimeException("not supported yet");
}
@Override
- public final void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr) {
+ public final void storeYCbCr(final int x, final int y, final byte Y, final byte Cb, final byte Cr) {
int i = ( ( height - y - 1 ) * width + x ) * storageComponents;
data.put(i++, Y);
data.put(i++, Cb);
@@ -118,7 +118,7 @@ public class JPEGImage {
}
};
- private JPEGImage(InputStream in, ColorSpace cs) throws IOException {
+ private JPEGImage(final InputStream in, final ColorSpace cs) throws IOException {
pixelStorage = new JPEGColorSink(cs);
final JPEGDecoder decoder = new JPEGDecoder();
decoder.parse(in);
@@ -139,9 +139,9 @@ public class JPEGImage {
}
decoder.clear(null);
}
- private JPEGColorSink pixelStorage;
+ private final JPEGColorSink pixelStorage;
private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel;
- private boolean reversedChannels;
+ private final boolean reversedChannels;
private final ByteBuffer data;
/** Returns the color space of the pixel data */
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java
index 3c90d96e4..f121478e7 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java
@@ -76,7 +76,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
*/
DataInputStream dataIn;
- public LEDataInputStream(InputStream in)
+ public LEDataInputStream(final InputStream in)
{
super(in);
dataIn = new DataInputStream(in);
@@ -90,32 +90,32 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
}
@Override
- public synchronized final int read(byte b[]) throws IOException
+ public synchronized final int read(final byte b[]) throws IOException
{
return dataIn.read(b, 0, b.length);
}
@Override
- public synchronized final int read(byte b[], int off, int len) throws IOException
+ public synchronized final int read(final byte b[], final int off, final int len) throws IOException
{
- int rl = dataIn.read(b, off, len);
+ final int rl = dataIn.read(b, off, len);
return rl;
}
@Override
- public final void readFully(byte b[]) throws IOException
+ public final void readFully(final byte b[]) throws IOException
{
dataIn.readFully(b, 0, b.length);
}
@Override
- public final void readFully(byte b[], int off, int len) throws IOException
+ public final void readFully(final byte b[], final int off, final int len) throws IOException
{
dataIn.readFully(b, off, len);
}
@Override
- public final int skipBytes(int n) throws IOException
+ public final int skipBytes(final int n) throws IOException
{
return dataIn.skipBytes(n);
}
@@ -123,7 +123,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final boolean readBoolean() throws IOException
{
- int ch = dataIn.read();
+ final int ch = dataIn.read();
if (ch < 0)
throw new EOFException();
return (ch != 0);
@@ -132,7 +132,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final byte readByte() throws IOException
{
- int ch = dataIn.read();
+ final int ch = dataIn.read();
if (ch < 0)
throw new EOFException();
return (byte)(ch);
@@ -141,7 +141,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final int readUnsignedByte() throws IOException
{
- int ch = dataIn.read();
+ final int ch = dataIn.read();
if (ch < 0)
throw new EOFException();
return ch;
@@ -150,8 +150,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final short readShort() throws IOException
{
- int ch1 = dataIn.read();
- int ch2 = dataIn.read();
+ final int ch1 = dataIn.read();
+ final int ch2 = dataIn.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (short)((ch1 << 0) + (ch2 << 8));
@@ -160,8 +160,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final int readUnsignedShort() throws IOException
{
- int ch1 = dataIn.read();
- int ch2 = dataIn.read();
+ final int ch1 = dataIn.read();
+ final int ch2 = dataIn.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (ch1 << 0) + (ch2 << 8);
@@ -170,8 +170,8 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final char readChar() throws IOException
{
- int ch1 = dataIn.read();
- int ch2 = dataIn.read();
+ final int ch1 = dataIn.read();
+ final int ch2 = dataIn.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (char)((ch1 << 0) + (ch2 << 8));
@@ -180,10 +180,10 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final int readInt() throws IOException
{
- int ch1 = dataIn.read();
- int ch2 = dataIn.read();
- int ch3 = dataIn.read();
- int ch4 = dataIn.read();
+ final int ch1 = dataIn.read();
+ final int ch2 = dataIn.read();
+ final int ch3 = dataIn.read();
+ final int ch4 = dataIn.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 0) + (ch2 << 8) + (ch3 << 16) + (ch4 << 24));
@@ -192,9 +192,9 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
@Override
public final long readLong() throws IOException
{
- int i1 = readInt();
- int i2 = readInt();
- return ((long)i1 & 0xFFFFFFFFL) + ((long)i2 << 32);
+ final int i1 = readInt();
+ final int i2 = readInt();
+ return (i1 & 0xFFFFFFFFL) + ((long)i2 << 32);
}
@Override
@@ -233,7 +233,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput
* dont call this it is not implemented
* @return empty new string
**/
- public final static String readUTF(DataInput in) throws IOException
+ public final static String readUTF(final DataInput in) throws IOException
{
return new String();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java
index 93b097500..add177546 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java
@@ -72,7 +72,7 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput
*/
DataOutputStream dataOut;
- public LEDataOutputStream(OutputStream out)
+ public LEDataOutputStream(final OutputStream out)
{
super(out);
dataOut = new DataOutputStream(out);
@@ -86,44 +86,44 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput
}
@Override
- public synchronized final void write(byte b[]) throws IOException
+ public synchronized final void write(final byte b[]) throws IOException
{
dataOut.write(b, 0, b.length);
}
@Override
- public synchronized final void write(byte b[], int off, int len) throws IOException
+ public synchronized final void write(final byte b[], final int off, final int len) throws IOException
{
dataOut.write(b, off, len);
}
@Override
- public final void write(int b) throws IOException
+ public final void write(final int b) throws IOException
{
dataOut.write(b);
}
@Override
- public final void writeBoolean(boolean v) throws IOException
+ public final void writeBoolean(final boolean v) throws IOException
{
dataOut.writeBoolean(v);
}
@Override
- public final void writeByte(int v) throws IOException
+ public final void writeByte(final int v) throws IOException
{
dataOut.writeByte(v);
}
/** Don't call this -- not implemented */
@Override
- public final void writeBytes(String s) throws IOException
+ public final void writeBytes(final String s) throws IOException
{
throw new UnsupportedOperationException();
}
@Override
- public final void writeChar(int v) throws IOException
+ public final void writeChar(final int v) throws IOException
{
dataOut.writeChar(((v >> 8) & 0xff) |
((v & 0xff) << 8));
@@ -131,25 +131,25 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput
/** Don't call this -- not implemented */
@Override
- public final void writeChars(String s) throws IOException
+ public final void writeChars(final String s) throws IOException
{
throw new UnsupportedOperationException();
}
@Override
- public final void writeDouble(double v) throws IOException
+ public final void writeDouble(final double v) throws IOException
{
writeLong(Double.doubleToRawLongBits(v));
}
@Override
- public final void writeFloat(float v) throws IOException
+ public final void writeFloat(final float v) throws IOException
{
writeInt(Float.floatToRawIntBits(v));
}
@Override
- public final void writeInt(int v) throws IOException
+ public final void writeInt(final int v) throws IOException
{
dataOut.writeInt((v >>> 24) |
((v >>> 8) & 0xff00) |
@@ -158,14 +158,14 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput
}
@Override
- public final void writeLong(long v) throws IOException
+ public final void writeLong(final long v) throws IOException
{
writeInt((int) v);
writeInt((int) (v >>> 32));
}
@Override
- public final void writeShort(int v) throws IOException
+ public final void writeShort(final int v) throws IOException
{
dataOut.writeShort(((v >> 8) & 0xff) |
((v & 0xff) << 8));
@@ -173,7 +173,7 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput
/** Don't call this -- not implemented */
@Override
- public final void writeUTF(String s) throws IOException
+ public final void writeUTF(final String s) throws IOException
{
throw new UnsupportedOperationException();
}
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 cabf4ebc5..461ddceb8 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
@@ -63,7 +63,7 @@ public class NetPbmTextureWriter implements TextureWriter {
* magic 7 - PAM binary RGB or RGBA
* </pre>
*/
- public NetPbmTextureWriter(int magic) {
+ public NetPbmTextureWriter(final int magic) {
switch(magic) {
case 0:
case 6:
@@ -85,7 +85,7 @@ public class NetPbmTextureWriter implements TextureWriter {
public String getSuffix() { return (magic==6)?PPM:PAM; }
@Override
- public boolean write(File file, TextureData data) throws IOException {
+ public boolean write(final File file, final TextureData data) throws IOException {
boolean res;
final int magic_old = magic;
@@ -107,12 +107,12 @@ public class NetPbmTextureWriter implements TextureWriter {
return res;
}
- private boolean writeImpl(File file, TextureData data) throws IOException {
+ private boolean writeImpl(final File file, final TextureData data) throws IOException {
int pixelFormat = data.getPixelFormat();
final int pixelType = data.getPixelType();
if ((pixelFormat == GL.GL_RGB ||
pixelFormat == GL.GL_RGBA ||
- pixelFormat == GL2.GL_BGR ||
+ pixelFormat == GL2GL3.GL_BGR ||
pixelFormat == GL.GL_BGRA ) &&
(pixelType == GL.GL_BYTE ||
pixelType == GL.GL_UNSIGNED_BYTE)) {
@@ -123,13 +123,13 @@ public class NetPbmTextureWriter implements TextureWriter {
}
buf.rewind();
- int comps = ( pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA ) ? 4 : 3 ;
+ final int comps = ( pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA ) ? 4 : 3 ;
- if( pixelFormat == GL2.GL_BGR || pixelFormat == GL.GL_BGRA ) {
+ if( pixelFormat == GL2GL3.GL_BGR || pixelFormat == GL.GL_BGRA ) {
// Must reverse order of red and blue channels to get correct results
for (int i = 0; i < buf.remaining(); i += comps) {
- byte red = buf.get(i + 0);
- byte blue = buf.get(i + 2);
+ final byte red = buf.get(i + 0);
+ final byte blue = buf.get(i + 2);
buf.put(i + 0, blue);
buf.put(i + 2, red);
}
@@ -141,9 +141,9 @@ public class NetPbmTextureWriter implements TextureWriter {
throw new IOException("NetPbmTextureWriter magic 6 (PPM) doesn't RGBA pixel format, use magic 7 (PAM)");
}
- FileOutputStream fos = IOUtil.getFileOutputStream(file, true);
+ final FileOutputStream fos = IOUtil.getFileOutputStream(file, true);
- StringBuilder header = new StringBuilder();
+ final StringBuilder header = new StringBuilder();
header.append("P");
header.append(magic);
header.append("\n");
@@ -173,7 +173,7 @@ public class NetPbmTextureWriter implements TextureWriter {
fos.write(header.toString().getBytes());
- FileChannel fosc = fos.getChannel();
+ final FileChannel fosc = fos.getChannel();
fosc.write(buf);
fosc.force(true);
fosc.close();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java
index cbc8e652f..27549dfe3 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java
@@ -54,7 +54,7 @@ import com.jogamp.common.util.IOUtil;
*/
public class SGIImage {
- private Header header;
+ private final Header header;
private int format;
private byte[] data;
// Used for decoding RLE-compressed images
@@ -105,7 +105,7 @@ public class SGIImage {
magic = MAGIC;
}
- Header(DataInputStream in) throws IOException {
+ Header(final DataInputStream in) throws IOException {
magic = in.readShort();
storage = in.readByte();
bpc = in.readByte();
@@ -116,13 +116,13 @@ public class SGIImage {
pixmin = in.readInt();
pixmax = in.readInt();
dummy = in.readInt();
- byte[] tmpname = new byte[80];
+ final byte[] tmpname = new byte[80];
in.read(tmpname);
int numChars = 0;
while (tmpname[numChars++] != 0);
imagename = new String(tmpname, 0, numChars);
colormap = in.readInt();
- byte[] tmp = new byte[404];
+ final byte[] tmp = new byte[404];
in.read(tmp);
}
@@ -142,21 +142,21 @@ public class SGIImage {
}
}
- private SGIImage(Header header) {
+ private SGIImage(final Header header) {
this.header = header;
}
/** Reads an SGI image from the specified file. */
- public static SGIImage read(String filename) throws IOException {
+ public static SGIImage read(final String filename) throws IOException {
return read(new FileInputStream(filename));
}
/** Reads an SGI image from the specified InputStream. */
- public static SGIImage read(InputStream in) throws IOException {
- DataInputStream dIn = new DataInputStream(new BufferedInputStream(in));
+ public static SGIImage read(final InputStream in) throws IOException {
+ final DataInputStream dIn = new DataInputStream(new BufferedInputStream(in));
- Header header = new Header(dIn);
- SGIImage res = new SGIImage(header);
+ final Header header = new Header(dIn);
+ final SGIImage res = new SGIImage(header);
res.decodeImage(dIn);
return res;
}
@@ -164,28 +164,28 @@ public class SGIImage {
/** Writes this SGIImage to the specified file name. If
flipVertically is set, outputs the scanlines from top to bottom
rather than the default bottom to top order. */
- public void write(String filename, boolean flipVertically) throws IOException {
+ public void write(final String filename, final boolean flipVertically) throws IOException {
write(new File(filename), flipVertically);
}
/** Writes this SGIImage to the specified file. If flipVertically is
set, outputs the scanlines from top to bottom rather than the
default bottom to top order. */
- public void write(File file, boolean flipVertically) throws IOException {
+ public void write(final File file, final boolean flipVertically) throws IOException {
writeImage(file, data, header.xsize, header.ysize, header.zsize, flipVertically);
}
/** Creates an SGIImage from the specified data in either RGB or
RGBA format. */
- public static SGIImage createFromData(int width,
- int height,
- boolean hasAlpha,
- byte[] data) {
- Header header = new Header();
+ public static SGIImage createFromData(final int width,
+ final int height,
+ final boolean hasAlpha,
+ final byte[] data) {
+ final Header header = new Header();
header.xsize = (short) width;
header.ysize = (short) height;
header.zsize = (short) (hasAlpha ? 4 : 3);
- SGIImage image = new SGIImage(header);
+ final SGIImage image = new SGIImage(header);
image.data = data;
return image;
}
@@ -201,9 +201,9 @@ public class SGIImage {
if (!in.markSupported()) {
throw new IOException("Can not test non-destructively whether given InputStream is an SGI RGB image");
}
- DataInputStream dIn = new DataInputStream(in);
+ final DataInputStream dIn = new DataInputStream(in);
dIn.mark(4);
- short magic = dIn.readShort();
+ final short magic = dIn.readShort();
dIn.reset();
return (magic == MAGIC);
}
@@ -236,10 +236,10 @@ public class SGIImage {
// Internals only below this point
//
- private void decodeImage(DataInputStream in) throws IOException {
+ private void decodeImage(final DataInputStream in) throws IOException {
if (header.storage == 1) {
// Read RLE compression data; row starts and sizes
- int x = header.ysize * header.zsize;
+ final int x = header.ysize * header.zsize;
rowStart = new int[x];
rowSize = new int[x];
rleEnd = 4 * 2 * x + 512;
@@ -253,16 +253,16 @@ public class SGIImage {
}
tmpData = readAll(in);
- int xsize = header.xsize;
- int ysize = header.ysize;
- int zsize = header.zsize;
+ final int xsize = header.xsize;
+ final int ysize = header.ysize;
+ final int zsize = header.zsize;
int lptr = 0;
data = new byte[xsize * ysize * 4];
- byte[] rbuf = new byte[xsize];
- byte[] gbuf = new byte[xsize];
- byte[] bbuf = new byte[xsize];
- byte[] abuf = new byte[xsize];
+ final byte[] rbuf = new byte[xsize];
+ final byte[] gbuf = new byte[xsize];
+ final byte[] bbuf = new byte[xsize];
+ final byte[] abuf = new byte[xsize];
for (int y = 0; y < ysize; y++) {
if (zsize >= 4) {
getRow(rbuf, y, 0);
@@ -293,15 +293,15 @@ public class SGIImage {
header.zsize = 4;
}
- private void getRow(byte[] buf, int y, int z) {
+ private void getRow(final byte[] buf, final int y, final int z) {
if (header.storage == 1) {
- int offs = rowStart[y + z * header.ysize] - rleEnd;
+ final int offs = rowStart[y + z * header.ysize] - rleEnd;
System.arraycopy(tmpData, offs, tmpRead, 0, rowSize[y + z * header.ysize]);
int iPtr = 0;
int oPtr = 0;
for (;;) {
byte pixel = tmpRead[iPtr++];
- int count = (int) (pixel & 0x7F);
+ int count = pixel & 0x7F;
if (count == 0) {
return;
}
@@ -317,12 +317,12 @@ public class SGIImage {
}
}
} else {
- int offs = (y * header.xsize) + (z * header.xsize * header.ysize);
+ final int offs = (y * header.xsize) + (z * header.xsize * header.ysize);
System.arraycopy(tmpData, offs, buf, 0, header.xsize);
}
}
- private void bwtorgba(byte[] b, byte[] dest, int lptr) {
+ private void bwtorgba(final byte[] b, final byte[] dest, final int lptr) {
for (int i = 0; i < b.length; i++) {
dest[4 * i + lptr + 0] = b[i];
dest[4 * i + lptr + 1] = b[i];
@@ -331,7 +331,7 @@ public class SGIImage {
}
}
- private void latorgba(byte[] b, byte[] a, byte[] dest, int lptr) {
+ private void latorgba(final byte[] b, final byte[] a, final byte[] dest, final int lptr) {
for (int i = 0; i < b.length; i++) {
dest[4 * i + lptr + 0] = b[i];
dest[4 * i + lptr + 1] = b[i];
@@ -340,7 +340,7 @@ public class SGIImage {
}
}
- private void rgbtorgba(byte[] r, byte[] g, byte[] b, byte[] dest, int lptr) {
+ private void rgbtorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] dest, final int lptr) {
for (int i = 0; i < b.length; i++) {
dest[4 * i + lptr + 0] = r[i];
dest[4 * i + lptr + 1] = g[i];
@@ -349,7 +349,7 @@ public class SGIImage {
}
}
- private void rgbatorgba(byte[] r, byte[] g, byte[] b, byte[] a, byte[] dest, int lptr) {
+ private void rgbatorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] a, final byte[] dest, final int lptr) {
for (int i = 0; i < b.length; i++) {
dest[4 * i + lptr + 0] = r[i];
dest[4 * i + lptr + 1] = g[i];
@@ -358,19 +358,19 @@ public class SGIImage {
}
}
- private static byte imgref(byte[] i,
- int x,
- int y,
- int z,
- int xs,
- int ys,
- int zs) {
+ private static byte imgref(final byte[] i,
+ final int x,
+ final int y,
+ final int z,
+ final int xs,
+ final int ys,
+ final int zs) {
return i[(xs*ys*z)+(xs*y)+x];
}
- private void writeHeader(DataOutputStream stream,
- int xsize, int ysize, int zsize, boolean rle) throws IOException {
+ private void writeHeader(final DataOutputStream stream,
+ final int xsize, final int ysize, final int zsize, final boolean rle) throws IOException {
// effects: outputs the 512-byte IRIS RGB header to STREAM, using xsize,
// ysize, and depth as the dimensions of the image. NOTE that
// the following defaults are used:
@@ -415,14 +415,14 @@ public class SGIImage {
stream.write(0);
}
- private void writeImage(File file,
+ private void writeImage(final File file,
byte[] data,
- int xsize,
- int ysize,
- int zsize,
- boolean yflip) throws IOException {
+ final int xsize,
+ final int ysize,
+ final int zsize,
+ final boolean yflip) throws IOException {
// Input data is in RGBRGBRGB or RGBARGBARGBA format; first unswizzle it
- byte[] tmpData = new byte[xsize * ysize * zsize];
+ final byte[] tmpData = new byte[xsize * ysize * zsize];
int dest = 0;
for (int i = 0; i < zsize; i++) {
for (int j = i; j < (xsize * ysize * zsize); j += zsize) {
@@ -447,8 +447,8 @@ public class SGIImage {
// x axis).
// Build the offset tables
- int[] starttab = new int[ysize * zsize];
- int[] lengthtab = new int[ysize * zsize];
+ final int[] starttab = new int[ysize * zsize];
+ final int[] lengthtab = new int[ysize * zsize];
// Temporary buffer for holding RLE data.
// Note that this makes the assumption that RLE-compressed data will
@@ -459,8 +459,8 @@ public class SGIImage {
// empirical evidence here; the break-even point seems to be a look-
// ahead of 3. (That is, if the three values following this one are all
// the same as the current value, switch to repeat mode.)
- int lookahead = 3;
- byte[] rlebuf = new byte[2 * xsize * ysize * zsize];
+ final int lookahead = 3;
+ final byte[] rlebuf = new byte[2 * xsize * ysize * zsize];
int cur_loc = 0; // current offset location.
int ptr = 0;
@@ -475,7 +475,7 @@ public class SGIImage {
yincr = -1;
}
- boolean DEBUG = false;
+ final boolean DEBUG = false;
for (int z = 0; z < zsize; z++) {
for (int y = ystart; y != yend; y += yincr) {
@@ -485,7 +485,7 @@ public class SGIImage {
byte count = 0;
boolean repeat_mode = false;
boolean should_switch = false;
- int start_ptr = ptr;
+ final int start_ptr = ptr;
int num_ptr = ptr++;
byte repeat_val = 0;
@@ -566,7 +566,7 @@ public class SGIImage {
x++;
}
// output this row's length into the length table
- int rowlen = ptr - start_ptr;
+ final int rowlen = ptr - start_ptr;
if (yflip)
lengthtab[ysize*z+(ysize-y-1)] = rowlen;
else
@@ -587,11 +587,11 @@ public class SGIImage {
if (DEBUG)
System.err.println("total_size was " + total_size);
- DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(IOUtil.getFileOutputStream(file, true)));
+ final DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(IOUtil.getFileOutputStream(file, true)));
writeHeader(stream, xsize, ysize, zsize, true);
- int SIZEOF_INT = 4;
+ final int SIZEOF_INT = 4;
for (int i = 0; i < (ysize * zsize); i++)
stream.writeInt(starttab[i] + 512 + (2 * ysize * zsize * SIZEOF_INT));
for (int i = 0; i < (ysize * zsize); i++)
@@ -602,7 +602,7 @@ public class SGIImage {
stream.close();
}
- private byte[] readAll(DataInputStream in) throws IOException {
+ private byte[] readAll(final DataInputStream in) throws IOException {
byte[] dest = new byte[16384];
int pos = 0;
int numRead = 0;
@@ -613,7 +613,7 @@ public class SGIImage {
numRead = in.read(dest, pos, dest.length - pos);
if (pos == dest.length) {
// Resize destination buffer
- byte[] newDest = new byte[2 * dest.length];
+ final byte[] newDest = new byte[2 * dest.length];
System.arraycopy(dest, 0, newDest, 0, pos);
dest = newDest;
}
@@ -626,7 +626,7 @@ public class SGIImage {
// Trim destination buffer
if (pos != dest.length) {
- byte[] finalDest = new byte[pos];
+ final byte[] finalDest = new byte[pos];
System.arraycopy(dest, 0, finalDest, 0, pos);
dest = finalDest;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java
index 15cd63eb3..28823abb3 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java
@@ -71,12 +71,12 @@ import com.jogamp.common.util.IOUtil;
*/
public class TGAImage {
- private Header header;
+ private final Header header;
private int format;
private int bpp;
private ByteBuffer data;
- private TGAImage(Header header) {
+ private TGAImage(final Header header) {
this.header = header;
}
@@ -114,7 +114,7 @@ public class TGAImage {
public final static int I_FOURWAY = 2;
/** Type of this TGA file format */
- private int tgaType;
+ private final int tgaType;
/** initial TGA image data fields */
private int idLength; // byte value
@@ -142,7 +142,7 @@ public class TGAImage {
tgaType = TYPE_OLD; // dont try and get footer.
}
- Header(LEDataInputStream in) throws IOException {
+ Header(final LEDataInputStream in) throws IOException {
tgaType = TYPE_OLD; // dont try and get footer.
// initial header fields
@@ -220,24 +220,24 @@ public class TGAImage {
public int size() { return 18 + idLength; }
// buf must be in little-endian byte order
- private void write(ByteBuffer buf) {
+ private void write(final ByteBuffer buf) {
buf.put((byte) idLength);
buf.put((byte) colorMapType);
buf.put((byte) imageType);
buf.putShort((short) firstEntryIndex);
buf.putShort((short) colorMapLength);
- buf.put((byte) colorMapEntrySize);
+ buf.put(colorMapEntrySize);
buf.putShort((short) xOrigin);
buf.putShort((short) yOrigin);
buf.putShort((short) width);
buf.putShort((short) height);
- buf.put((byte) pixelDepth);
- buf.put((byte) imageDescriptor);
+ buf.put(pixelDepth);
+ buf.put(imageDescriptor);
if (idLength > 0) {
try {
- byte[] chars = imageID.getBytes("US-ASCII");
+ final byte[] chars = imageID.getBytes("US-ASCII");
buf.put(chars);
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@@ -250,7 +250,7 @@ public class TGAImage {
* it into the JimiImage structure. This was taken from the
* prototype and modified for the new Jimi structure
*/
- private void decodeImage(GLProfile glp, LEDataInputStream dIn) throws IOException {
+ private void decodeImage(final GLProfile glp, final LEDataInputStream dIn) throws IOException {
switch (header.imageType()) {
case Header.UCOLORMAPPED:
throw new IOException("TGADecoder Uncompressed Colormapped images not supported");
@@ -294,14 +294,14 @@ public class TGAImage {
* This assumes that the body is for a 24 bit or 32 bit for a
* RGB or ARGB image respectively.
*/
- private void decodeRGBImageU24_32(GLProfile glp, LEDataInputStream dIn) throws IOException {
+ private void decodeRGBImageU24_32(final GLProfile glp, final LEDataInputStream dIn) throws IOException {
setupImage24_32(glp);
int i; // row index
int y; // output row index
- int rawWidth = header.width() * bpp;
- byte[] rawBuf = new byte[rawWidth];
- byte[] tmpData = new byte[rawWidth * header.height()];
+ final int rawWidth = header.width() * bpp;
+ final byte[] rawBuf = new byte[rawWidth];
+ final byte[] tmpData = new byte[rawWidth * header.height()];
for (i = 0; i < header.height(); ++i) {
dIn.readFully(rawBuf, 0, rawWidth);
@@ -323,12 +323,12 @@ public class TGAImage {
* This assumes that the body is for a 24 bit or 32 bit for a
* RGB or ARGB image respectively.
*/
- private void decodeRGBImageRLE24_32(GLProfile glp, LEDataInputStream dIn) throws IOException {
+ private void decodeRGBImageRLE24_32(final GLProfile glp, final LEDataInputStream dIn) throws IOException {
setupImage24_32(glp);
- byte[] pixel = new byte[bpp];
- int rawWidth = header.width() * bpp;
- byte[] tmpData = new byte[rawWidth * header.height()];
+ final byte[] pixel = new byte[bpp];
+ final int rawWidth = header.width() * bpp;
+ final byte[] tmpData = new byte[rawWidth * header.height()];
int i = 0, j;
int packet, len;
while (i < tmpData.length) {
@@ -348,7 +348,7 @@ public class TGAImage {
data = ByteBuffer.wrap(tmpData);
}
- private void setupImage24_32(GLProfile glp) {
+ private void setupImage24_32(final GLProfile glp) {
bpp = header.pixelDepth / 8;
switch (header.pixelDepth) {
case 24:
@@ -367,7 +367,7 @@ public class TGAImage {
}
}
- private static void swapBGR(byte[] data, int bWidth, int height, int bpp) {
+ private static void swapBGR(final byte[] data, final int bWidth, final int height, final int bpp) {
byte r,b;
int k;
for(int i=0; i<height; ++i) {
@@ -398,30 +398,30 @@ public class TGAImage {
public ByteBuffer getData() { return data; }
/** Reads a Targa image from the specified file. */
- public static TGAImage read(GLProfile glp, String filename) throws IOException {
+ public static TGAImage read(final GLProfile glp, final String filename) throws IOException {
return read(glp, new FileInputStream(filename));
}
/** Reads a Targa image from the specified InputStream. */
- public static TGAImage read(GLProfile glp, InputStream in) throws IOException {
- LEDataInputStream dIn = new LEDataInputStream(new BufferedInputStream(in));
+ public static TGAImage read(final GLProfile glp, final InputStream in) throws IOException {
+ final LEDataInputStream dIn = new LEDataInputStream(new BufferedInputStream(in));
- Header header = new Header(dIn);
- TGAImage res = new TGAImage(header);
+ final Header header = new Header(dIn);
+ final TGAImage res = new TGAImage(header);
res.decodeImage(glp, dIn);
return res;
}
/** Writes the image in Targa format to the specified file name. */
- public void write(String filename) throws IOException {
+ public void write(final String filename) throws IOException {
write(new File(filename));
}
/** Writes the image in Targa format to the specified file. */
- public void write(File file) throws IOException {
- FileOutputStream stream = IOUtil.getFileOutputStream(file, true);
- FileChannel chan = stream.getChannel();
- ByteBuffer buf = ByteBuffer.allocate(header.size());
+ public void write(final File file) throws IOException {
+ final FileOutputStream stream = IOUtil.getFileOutputStream(file, true);
+ final FileChannel chan = stream.getChannel();
+ final ByteBuffer buf = ByteBuffer.allocate(header.size());
buf.order(ByteOrder.LITTLE_ENDIAN);
header.write(buf);
buf.rewind();
@@ -437,19 +437,19 @@ public class TGAImage {
data with the passed ByteBuffer. Assumes the data is already in
the correct byte order for writing to disk, i.e., BGR or
BGRA. */
- public static TGAImage createFromData(int width,
- int height,
- boolean hasAlpha,
- boolean topToBottom,
- ByteBuffer data) {
- Header header = new Header();
+ public static TGAImage createFromData(final int width,
+ final int height,
+ final boolean hasAlpha,
+ final boolean topToBottom,
+ final ByteBuffer data) {
+ final Header header = new Header();
header.imageType = Header.UTRUECOLOR;
header.width = width;
header.height = height;
header.pixelDepth = (byte) (hasAlpha ? 32 : 24);
header.imageDescriptor = (byte) (topToBottom ? Header.ID_TOPTOBOTTOM : 0);
// Note ID not supported
- TGAImage ret = new TGAImage(header);
+ final TGAImage ret = new TGAImage(header);
ret.data = data;
return ret;
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java
index 18ad429d2..4174adf52 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java
@@ -55,12 +55,12 @@ public class IIOTextureProvider implements TextureProvider {
private static final boolean DEBUG = Debug.debug("TextureIO");
@Override
- public TextureData newTextureData(GLProfile glp, File file,
- int internalFormat,
- int pixelFormat,
- boolean mipmap,
- String fileSuffix) throws IOException {
- BufferedImage img = ImageIO.read(file);
+ public TextureData newTextureData(final GLProfile glp, final File file,
+ final int internalFormat,
+ final int pixelFormat,
+ final boolean mipmap,
+ final String fileSuffix) throws IOException {
+ final BufferedImage img = ImageIO.read(file);
if (img == null) {
return null;
}
@@ -72,12 +72,12 @@ public class IIOTextureProvider implements TextureProvider {
}
@Override
- public TextureData newTextureData(GLProfile glp, InputStream stream,
- int internalFormat,
- int pixelFormat,
- boolean mipmap,
- String fileSuffix) throws IOException {
- BufferedImage img = ImageIO.read(stream);
+ public TextureData newTextureData(final GLProfile glp, final InputStream stream,
+ final int internalFormat,
+ final int pixelFormat,
+ final boolean mipmap,
+ final String fileSuffix) throws IOException {
+ final BufferedImage img = ImageIO.read(stream);
if (img == null) {
return null;
}
@@ -89,12 +89,12 @@ public class IIOTextureProvider implements TextureProvider {
}
@Override
- public TextureData newTextureData(GLProfile glp, URL url,
- int internalFormat,
- int pixelFormat,
- boolean mipmap,
- String fileSuffix) throws IOException {
- InputStream stream = url.openStream();
+ public TextureData newTextureData(final GLProfile glp, final URL url,
+ final int internalFormat,
+ final int pixelFormat,
+ final boolean mipmap,
+ final String fileSuffix) throws IOException {
+ final InputStream stream = url.openStream();
try {
return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix);
} finally {
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 be82e4fb8..60ac5680e 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
@@ -54,10 +54,10 @@ import com.jogamp.opengl.util.texture.spi.*;
public class IIOTextureWriter implements TextureWriter {
@Override
- public boolean write(File file,
- TextureData data) throws IOException {
- int pixelFormat = data.getPixelFormat();
- int pixelType = data.getPixelType();
+ public boolean write(final File file,
+ final TextureData data) throws IOException {
+ final int pixelFormat = data.getPixelFormat();
+ final int pixelType = data.getPixelType();
if ((pixelFormat == GL.GL_RGB ||
pixelFormat == GL.GL_RGBA) &&
(pixelType == GL.GL_BYTE ||
@@ -68,7 +68,7 @@ public class IIOTextureWriter implements TextureWriter {
(pixelFormat == GL.GL_RGB) ?
BufferedImage.TYPE_3BYTE_BGR :
BufferedImage.TYPE_4BYTE_ABGR);
- byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
+ final byte[] imageData = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
ByteBuffer buf = (ByteBuffer) data.getBuffer();
if (buf == null) {
buf = (ByteBuffer) data.getMipmapData()[0];
@@ -80,17 +80,17 @@ public class IIOTextureWriter implements TextureWriter {
// Swizzle image components to be correct
if (pixelFormat == GL.GL_RGB) {
for (int i = 0; i < imageData.length; i += 3) {
- byte red = imageData[i + 0];
- byte blue = imageData[i + 2];
+ final byte red = imageData[i + 0];
+ final byte blue = imageData[i + 2];
imageData[i + 0] = blue;
imageData[i + 2] = red;
}
} else {
for (int i = 0; i < imageData.length; i += 4) {
- byte red = imageData[i + 0];
- byte green = imageData[i + 1];
- byte blue = imageData[i + 2];
- byte alpha = imageData[i + 3];
+ final byte red = imageData[i + 0];
+ final byte green = imageData[i + 1];
+ final byte blue = imageData[i + 2];
+ final byte alpha = imageData[i + 3];
imageData[i + 0] = alpha;
imageData[i + 1] = blue;
imageData[i + 2] = green;
@@ -104,9 +104,9 @@ public class IIOTextureWriter implements TextureWriter {
// Happened to notice that writing RGBA images to JPEGS is broken
if (TextureIO.JPG.equals(IOUtil.getFileSuffix(file)) &&
image.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
- BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(),
+ final BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(),
BufferedImage.TYPE_3BYTE_BGR);
- Graphics g = tmpImage.getGraphics();
+ final Graphics g = tmpImage.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
image = tmpImage;