Top Description Inners Fields Constructors Methods
com.jogamp.opengl.util.texture.spi

public Class SGIImage

extends Object
Class Inheritance
Imports
java.io.*, com.jogamp.opengl.*, com.jogamp.opengl.util.texture.ImageType, com.jogamp.common.util.IOUtil

Reads and writes SGI RGB/RGBA images.

Written from Paul Bourke's adaptation of the SGI specification.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private final SGIImage.Header
private static final int
private int
private int[]
private int[]
private byte[]
private byte[]

Constructor Summary

AccessConstructor and Description
private
SGIImage(final SGIImage.Header header)

Method Summary

Modifier and TypeMethod and Description
private void
bwtorgba(final byte[] b, final byte[] dest, final int lptr)

public static SGIImage
createFromData(final int width, final int height, final boolean hasAlpha, final byte[] data)

Creates an SGIImage from the specified data in either RGB or RGBA format.

private void
public byte[]
getData()

Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.

public int
getFormat()

Returns the OpenGL format for this texture; e.g. GL.GL_RGB or GL.GL_RGBA.

public int
getHeight()

Returns the height of the image.

private void
getRow(final byte[] buf, final int y, final int z)

public int
getWidth()

Returns the width of the image.

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)

public static boolean
isSGIImage(InputStream in)

Deprecated rather call ImageType#getFileSuffix(InputStream)
Determines from the magic number whether the given InputStream points to an SGI RGB image.
private void
latorgba(final byte[] b, final byte[] a, final byte[] dest, final int lptr)

public static SGIImage
read(final String filename)

Reads an SGI image from the specified file.

public static SGIImage
read(final InputStream in)

Reads an SGI image from the specified InputStream.

private byte[]
private void
rgbatorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] a, final byte[] dest, final int lptr)

private void
rgbtorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] dest, final int lptr)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(final String filename, final boolean flipVertically)

Writes this SGIImage to the specified file name.

public void
write(final File file, final boolean flipVertically)

Writes this SGIImage to the specified file.

private void
writeHeader(final DataOutputStream stream, final int xsize, final int ysize, final int zsize, final boolean rle)

private void
writeImage(final File file, byte[] data, final int xsize, final int ysize, final int zsize, final boolean yflip)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

databack to summary
private byte[] data
formatback to summary
private int format
MAGICback to summary
private static final int MAGIC
rleEndback to summary
private int rleEnd
rowSizeback to summary
private int[] rowSize
rowStartback to summary
private int[] rowStart
tmpDataback to summary
private byte[] tmpData
tmpReadback to summary
private byte[] tmpRead

Constructor Detail

SGIImageback to summary
private SGIImage(final SGIImage.Header header)

Method Detail

bwtorgbaback to summary
private void bwtorgba(final byte[] b, final byte[] dest, final int lptr)
createFromDataback to summary
public static SGIImage createFromData(final int width, final int height, final boolean hasAlpha, final byte[] data)

Creates an SGIImage from the specified data in either RGB or RGBA format.

decodeImageback to summary
private void decodeImage(final DataInputStream in) throws IOException
getDataback to summary
public byte[] getData()

Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.

getFormatback to summary
public int getFormat()

Returns the OpenGL format for this texture; e.g. GL.GL_RGB or GL.GL_RGBA.

getHeightback to summary
public int getHeight()

Returns the height of the image.

getRowback to summary
private void getRow(final byte[] buf, final int y, final int z)
getWidthback to summary
public int getWidth()

Returns the width of the image.

imgrefback to summary
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)
isSGIImageback to summary
public static boolean isSGIImage(InputStream in) throws IOException

Deprecated

rather call ImageType#getFileSuffix(InputStream)

Determines from the magic number whether the given InputStream points to an SGI RGB image. The given InputStream must return true from markSupported() and support a minimum of two bytes of read-ahead.

Annotations
@Deprecated
latorgbaback to summary
private void latorgba(final byte[] b, final byte[] a, final byte[] dest, final int lptr)
readback to summary
public static SGIImage read(final String filename) throws IOException

Reads an SGI image from the specified file.

readback to summary
public static SGIImage read(final InputStream in) throws IOException

Reads an SGI image from the specified InputStream.

readAllback to summary
private byte[] readAll(final DataInputStream in) throws IOException
rgbatorgbaback to summary
private void rgbatorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] a, final byte[] dest, final int lptr)
rgbtorgbaback to summary
private void rgbtorgba(final byte[] r, final byte[] g, final byte[] b, final byte[] dest, final int lptr)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeback to summary
public void write(final String filename, final boolean flipVertically) throws IOException

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.

writeback to summary
public void write(final File file, final boolean flipVertically) throws IOException

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.

writeHeaderback to summary
private void writeHeader(final DataOutputStream stream, final int xsize, final int ysize, final int zsize, final boolean rle) throws IOException
writeImageback to summary
private void writeImage(final File file, byte[] data, final int xsize, final int ysize, final int zsize, final boolean yflip) throws IOException