|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.opengl.util.texture.spi.DDSImage
public class DDSImage
A reader and writer for DirectDraw Surface (.dds) files, which are used to describe textures. These files can contain multiple mipmap levels in one file. This class is currently minimal and does not support all of the possible file formats.
Nested Class Summary | |
---|---|
static class |
DDSImage.ImageInfo
Simple class describing images and data; does not encapsulate image format information. |
Method Summary | |
---|---|
static ByteBuffer |
allocateBlankBuffer(int width,
int height,
int openGLInternalFormat)
Allocates a temporary, empty ByteBuffer suitable for use in a call to glCompressedTexImage2D. |
void |
close()
Closes open files and resources associated with the open DDSImage. |
static DDSImage |
createFromData(int d3dFormat,
int width,
int height,
ByteBuffer[] mipmapData)
Creates a new DDSImage from data supplied by the user. |
void |
debugPrint()
|
DDSImage.ImageInfo[] |
getAllMipMaps()
Returns an array of ImageInfos corresponding to all mipmap levels of this DDS file. |
DDSImage.ImageInfo[] |
getAllMipMaps(int side)
Returns an array of ImageInfos corresponding to all mipmap levels of this DDS file. |
int |
getCompressionFormat()
If this surface is compressed, returns the kind of compression used (DXT1..DXT5). |
static String |
getCompressionFormatName(int compressionFormat)
Converts e.g. |
int |
getDepth()
Total number of bits per pixel. |
int |
getHeight()
Height of the texture (or the top-most mipmap if mipmaps are present) |
DDSImage.ImageInfo |
getMipMap(int map)
Gets the ith mipmap data (0..getNumMipMaps() - 1) |
DDSImage.ImageInfo |
getMipMap(int side,
int map)
Gets the ith mipmap data (0..getNumMipMaps() - 1) |
int |
getNumMipMaps()
Number of mip maps in the texture |
int |
getPixelFormat()
Gets the pixel format of this texture (D3DFMT_*) based on some heuristics. |
int |
getWidth()
Width of the texture (or the top-most mipmap if mipmaps are present) |
boolean |
isCompressed()
Indicates whether this texture is compressed. |
boolean |
isCubemap()
Indicates whether this texture is cubemap |
boolean |
isCubemapSidePresent(int side)
Indicates whethe this cubemap side present |
static boolean |
isDDSImage(InputStream in)
Determines from the magic number whether the given InputStream points to a DDS image. |
boolean |
isPixelFormatFlagSet(int flag)
Test for presence/absence of pixel format flags (DDPF_*) |
boolean |
isSurfaceDescFlagSet(int flag)
Test for presence/absence of surface description flags (DDSD_*) |
static DDSImage |
read(ByteBuffer buf)
Reads a DirectDraw surface from the specified ByteBuffer, returning the resulting DDSImage. |
static DDSImage |
read(File file)
Reads a DirectDraw surface from the specified file, returning the resulting DDSImage. |
static DDSImage |
read(String filename)
Reads a DirectDraw surface from the specified file name, returning the resulting DDSImage. |
void |
write(File file)
Writes this DDSImage to the specified file name. |
void |
write(String filename)
Writes this DDSImage to the specified file name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DDSD_CAPS
public static final int DDSD_HEIGHT
public static final int DDSD_WIDTH
public static final int DDSD_PITCH
public static final int DDSD_BACKBUFFERCOUNT
public static final int DDSD_ZBUFFERBITDEPTH
public static final int DDSD_ALPHABITDEPTH
public static final int DDSD_LPSURFACE
public static final int DDSD_PIXELFORMAT
public static final int DDSD_MIPMAPCOUNT
public static final int DDSD_LINEARSIZE
public static final int DDSD_DEPTH
public static final int DDPF_ALPHAPIXELS
public static final int DDPF_ALPHA
public static final int DDPF_FOURCC
public static final int DDPF_PALETTEINDEXED4
public static final int DDPF_PALETTEINDEXEDTO8
public static final int DDPF_PALETTEINDEXED8
public static final int DDPF_RGB
public static final int DDPF_COMPRESSED
public static final int DDPF_RGBTOYUV
public static final int DDPF_YUV
public static final int DDPF_ZBUFFER
public static final int DDPF_PALETTEINDEXED1
public static final int DDPF_PALETTEINDEXED2
public static final int DDPF_ZPIXELS
public static final int DDSCAPS_TEXTURE
public static final int DDSCAPS_MIPMAP
public static final int DDSCAPS_COMPLEX
public static final int DDSCAPS2_CUBEMAP
public static final int DDSCAPS2_CUBEMAP_POSITIVEX
public static final int DDSCAPS2_CUBEMAP_NEGATIVEX
public static final int DDSCAPS2_CUBEMAP_POSITIVEY
public static final int DDSCAPS2_CUBEMAP_NEGATIVEY
public static final int DDSCAPS2_CUBEMAP_POSITIVEZ
public static final int DDSCAPS2_CUBEMAP_NEGATIVEZ
public static final int D3DFMT_UNKNOWN
public static final int D3DFMT_R8G8B8
public static final int D3DFMT_A8R8G8B8
public static final int D3DFMT_X8R8G8B8
public static final int D3DFMT_DXT1
public static final int D3DFMT_DXT2
public static final int D3DFMT_DXT3
public static final int D3DFMT_DXT4
public static final int D3DFMT_DXT5
Method Detail |
---|
public static DDSImage read(String filename) throws IOException
filename
- File name
IOException
- if an I/O exception occurredpublic static DDSImage read(File file) throws IOException
file
- File object
IOException
- if an I/O exception occurredpublic static DDSImage read(ByteBuffer buf) throws IOException
buf
- Input data
IOException
- if an I/O exception occurredpublic void close()
public static DDSImage createFromData(int d3dFormat, int width, int height, ByteBuffer[] mipmapData) throws IllegalArgumentException
d3dFormat
- the D3DFMT_ constant describing the data; it is
assumed that it is packed tightlywidth
- the width in pixels of the topmost mipmap imageheight
- the height in pixels of the topmost mipmap imagemipmapData
- the data for each mipmap level of the resulting
DDSImage; either only one mipmap level should
be specified, or they all must be
IllegalArgumentException
- if the data does not match the
specified argumentspublic static boolean isDDSImage(InputStream in) throws IOException
in
- Stream to check
IOException
- if an I/O exception occurredpublic void write(String filename) throws IOException
filename
- File name to write to
IOException
- if an I/O exception occurredpublic void write(File file) throws IOException
file
- File object to write to
IOException
- if an I/O exception occurredpublic boolean isSurfaceDescFlagSet(int flag)
flag
- DDSD_* flags set to test
public boolean isPixelFormatFlagSet(int flag)
public int getPixelFormat()
public boolean isCubemap()
public boolean isCubemapSidePresent(int side)
side
- Side to test
public boolean isCompressed()
public int getCompressionFormat()
public int getWidth()
public int getHeight()
public int getDepth()
public int getNumMipMaps()
public DDSImage.ImageInfo getMipMap(int map)
map
- Mipmap index
public DDSImage.ImageInfo getMipMap(int side, int map)
side
- Cubemap side or 0 for 2D texturemap
- Mipmap index
public DDSImage.ImageInfo[] getAllMipMaps()
public DDSImage.ImageInfo[] getAllMipMaps(int side)
side
- Cubemap side or 0 for 2D texture
public static String getCompressionFormatName(int compressionFormat)
getCompressionFormat()
) into "DXT1".
compressionFormat
- Compression format constant
public static ByteBuffer allocateBlankBuffer(int width, int height, int openGLInternalFormat)
public void debugPrint()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |