public class DDSImage extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DDSImage.ImageInfo
Simple class describing images and data; does not encapsulate
image format information.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
public static DDSImage read(String filename) throws IOException
filename
- File nameIOException
- if an I/O exception occurredpublic static DDSImage read(File file) throws IOException
file
- File objectIOException
- if an I/O exception occurredpublic static DDSImage read(ByteBuffer buf) throws IOException
buf
- Input dataIOException
- 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 beIllegalArgumentException
- if the data does not match the
specified argumentspublic static boolean isDDSImage(InputStream in) throws IOException
in
- Stream to checkIOException
- if an I/O exception occurredpublic void write(String filename) throws IOException
filename
- File name to write toIOException
- if an I/O exception occurredpublic void write(File file) throws IOException
file
- File object to write toIOException
- if an I/O exception occurredpublic boolean isSurfaceDescFlagSet(int flag)
flag
- DDSD_* flags set to testpublic boolean isPixelFormatFlagSet(int flag)
public int getPixelFormat()
public boolean isCubemap()
public boolean isCubemapSidePresent(int side)
side
- Side to testpublic 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 indexpublic DDSImage.ImageInfo getMipMap(int side, int map)
side
- Cubemap side or 0 for 2D texturemap
- Mipmap indexpublic DDSImage.ImageInfo[] getAllMipMaps()
public DDSImage.ImageInfo[] getAllMipMaps(int side)
side
- Cubemap side or 0 for 2D texturepublic static String getCompressionFormatName(int compressionFormat)
getCompressionFormat()
) into "DXT1".compressionFormat
- Compression format constantpublic static ByteBuffer allocateBlankBuffer(int width, int height, int openGLInternalFormat)
public void debugPrint()
Copyright 2010 JogAmp Community.