#include <image.h>
|
void | SetReleaseImageDataEnabled (bool enable) |
|
bool | IsReleaseImageDataEnabled () |
|
virtual int | ErrorFound (void) |
|
virtual void | SetError (char *errorMessage) |
|
virtual char * | GetError (void) |
|
virtual void | Draw (void) |
|
virtual void | Draw (int x, int y) |
|
virtual Image * | Clone () |
|
virtual unsigned char * | ImageData (void) |
|
virtual float | TextureCoordX (void) |
|
virtual float | TextureCoordY (void) |
|
virtual int | TextureWidth (void) |
|
virtual int | TextureHeight (void) |
|
virtual int | Size (void) |
|
virtual int | Width (void) |
|
virtual int | Height (void) |
|
virtual bool | TextureHandleValid () |
|
virtual unsigned int | TextureHandle () const |
|
virtual int | PixelFormat (void) |
|
virtual void | PixelFormat (int format) |
|
virtual char * | PixelFormatString (void) |
|
virtual int | PixelSize (void) |
|
virtual unsigned char * | GetRasterPosition (int x, int y) |
|
virtual void | SetPixel (int x, int y, float color[]) |
|
virtual void | SetAsCurrentTexture (void) |
|
virtual void | AllocateTextureBinding (void) |
|
virtual void | DeallocateTextureBinding (void) |
|
virtual void | BindTexture (void) |
|
| Image (const unsigned char *const data, int width, int height, int pixelFormat) |
|
| Image (int width, int height, int pixelSize, bool allowNPOT=false) |
|
| Image (const glsInlineImage &image) |
|
| Image (int width, int height, int components, int format, unsigned int comprLen, const unsigned char *const data[], unsigned long crcVal=0, int lineLength=320) |
|
| Image (int width, int height, int components, int format, const unsigned char *const pix[], unsigned long crcVal=0, int lineLength=320) |
|
| Image (const Image &source) |
|
| Image (void) |
|
void | UnloadRgbData () |
|
virtual void | DeleteUsage () |
|
virtual void | AddUsage () |
|
virtual int | NumUsers () |
|
virtual void | operator= (Image &im) |
|
virtual void | ScaleTexture (void) |
|
virtual unsigned long | CrcValue () |
|
virtual int | operator== (Image &im) |
|
virtual Image * | FindDuplicate () |
|
virtual void | MipMap (bool set) |
|
virtual bool | MipMap () |
|
virtual void | GlTextureCompression (bool set) |
|
virtual bool | GlTextureCompression () |
|
virtual void | ScaleToPowerOfTwo (void) |
|
virtual void | ReplaceImage (unsigned char *imageData) |
|
virtual bool | ReplaceImage (unsigned char *imageData, int width, int height, int pixelSize) |
|
virtual bool | LoadInlineImageData () |
|
virtual bool | FreeInlineImageData () |
|
virtual bool | DisconnectInlineImage (bool loadImage=true) |
|
virtual void | AllowImageSharing (bool value) |
|
bool | IsAllowNPOTTextures (void) const |
|
The Image class. Implements loading 2D image files.
Image |
( |
const unsigned char *const |
data, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
pixelFormat |
|
) |
| |
Create an Image object with the specified image data and image size.
- Parameters
-
data | Pointer to the image data |
width | Width of the image |
height | Height of the image |
pixelFormat | The format of each pixel, eg. GL_RGBA |
Image |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
pixelSize, |
|
|
bool |
allowNPOT = false |
|
) |
| |
Create an Image object with the specified image size.
- Parameters
-
width | Width of the image |
height | Height of the image |
pixelSize | The size in bytes of each pixel |
allowNPOT | If the image is allowed to be non-power of two (NPOT) |
Create an Image from an inline image (GL Studio 2.2 and later API)
- Parameters
-
image | Structure containing details of inline image |
Image |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
components, |
|
|
int |
format, |
|
|
unsigned int |
comprLen, |
|
|
const unsigned char *const |
data[], |
|
|
unsigned long |
crcVal = 0 , |
|
|
int |
lineLength = 320 |
|
) |
| |
Create an Image from a buffer of ZLIB compressed data Image data must already be a power of two!
- Parameters
-
width | Width of the image |
height | Height of the image |
components | The size in bytes of each pixel |
format | The OpenGL texture format to use |
comprLen | The size of the compressed image |
data | The buffer of compressed data |
crcVal | The CRC value used to find duplicate textures |
lineLength | The number of bytes in each inline image line |
Image |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
components, |
|
|
int |
format, |
|
|
const unsigned char *const |
pix[], |
|
|
unsigned long |
crcVal = 0 , |
|
|
int |
lineLength = 320 |
|
) |
| |
Create an Image from a buffer of uncompressed data Image data must already be a power of two!
- Parameters
-
width | Width of the image |
height | Height of the image |
components | The size in bytes of each pixel |
format | The OpenGL texture format to use |
pix | The buffer of uncompressed data |
crcVal | The CRC value used to find duplicate textures |
lineLength | The number of bytes in each inline image line |
Constructor for an Image object.
Destroy an Image object. Frees the memory for the RGB buffer.
void AddSelfToInstanceList |
( |
| ) |
|
|
protected |
Add this image to the Image Sharing Instance List
virtual void AddUsage |
( |
| ) |
|
|
virtual |
Lets this object know that another something is using this image
virtual bool AllocateMipMapMemory |
( |
bool |
zeroOut = true | ) |
|
|
protectedvirtual |
Allocate memory for Mip-Map images
- Parameters
-
zeroOut | Whether or not to clear the memory to zero on allocation. |
virtual bool AllocatePixelMemory |
( |
bool |
zeroOut = true | ) |
|
|
protectedvirtual |
Allocate and initialize the pixel buffer memory for this image _texWidth, _textHeight and _pixelSize must be initialized prior to calling! _rgbBuf is set to the initialized memory.
- Parameters
-
zeroOut | Whether or not to clear the memory to zero on allocation. |
- Returns
- True if allocated. false on failure.
virtual void AllocateTextureBinding |
( |
void |
| ) |
|
|
virtual |
Create a new texture object using Image object data.
virtual void AllowImageSharing |
( |
bool |
value | ) |
|
|
virtual |
If AllowImageSharing is true, this Image may be deleted by the texture palette if a duplicate texture is found. This also implies that the Image will not change and may be used in place of another texture with the same CrcValue(). If false this causes Image::CrcValue() to always return 0, disabling duplicate checking. (default: true) Note: If this Image is already in a TexturePalette, you should call TexturePalette::DisableImageSharing() instead of this method.
virtual void BindTexture |
( |
void |
| ) |
|
|
virtual |
virtual void CalculateMipMapImages |
( |
bool |
reCalc = false | ) |
|
|
protectedvirtual |
Calculate mip-map images from the main image
- Returns
- A new image that is a duplicate of this image or NULL if duplication is not possible.
void ConvertLuminanceAlphaToAlpha |
( |
| ) |
|
|
protected |
Convert Luminance Alpha texture to Alpha texture. Used on OpenGL ES target to speedup texturing for fonts
virtual unsigned long CrcValue |
( |
| ) |
|
|
virtual |
- Returns
- the CRC value for this image. 0 indicates an invalid value or that duplicate checking is disabled for the Image.
virtual void DeallocateTextureBinding |
( |
void |
| ) |
|
|
virtual |
Deletes the OpenGL texture object for this Image.
virtual void DeleteUsage |
( |
| ) |
|
|
virtual |
Will delete the Image object if nobody is using it
virtual bool DisconnectInlineImage |
( |
bool |
loadImage = true | ) |
|
|
virtual |
Removes the association between this Image and it's glsInlineImage data. This will use more memory, but makes the Image independent of the static data. This method will attempt to load the image before disconnecting from the glsInlineImage, if the load fails, ImageData() will return NULL afterwards. After calling this method, the Image will no longer have a glsInlineImage associated with it.
- Parameters
-
loadImage | If true, the _rgbBuf will be loaded from the inline image data before disconnecting If false, the _rgbBuf will be allocated but not initialized. |
- Returns
- true if the Image had a glsInlineImage associated with it
-
false if the Image did not have a glsInlineImage associated with it.
virtual void Draw |
( |
void |
| ) |
|
|
virtual |
Draws the image at the current raster position.
virtual void Draw |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
virtual |
Draws the image at the x,y raster position specified.
- Parameters
-
x | X position to draw the image |
y | Y position to draw the image |
static void EmptyInstanceList |
( |
| ) |
|
|
static |
Empties the InstanceList This is done when loading objects which will be drawn in different OpenGL contexts.
virtual int ErrorFound |
( |
void |
| ) |
|
|
virtual |
- Returns
- The state of any error found reading image file flag.
virtual Image* FindDuplicate |
( |
| ) |
|
|
virtual |
Tries to find an image that is the same as this image
- Returns
- A pointer to the first image in the image instance list that matches or NULL if not found
static Image* FindDuplicate |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
components, |
|
|
unsigned long |
crcVal, |
|
|
bool |
glTexCompress |
|
) |
| |
|
static |
Tries to find an image that is the same as a notional image based on the following criteria
- Parameters
-
width | Width of notional image |
height | Height of notional image |
components | Number of components in the notional image |
crcVal | 32 bit CRC of notional image |
glTexCompress | GlTextureCompresssion setting for the image |
- Returns
- A pointer to the first image in the image instance list that matches or NULL if not found
virtual bool FreeInlineImageData |
( |
| ) |
|
|
virtual |
Frees the local rgb buffer if this image has a glsInlineImage associated with it.
- Returns
- true if the buffer was freed, false if this Image does not have a glsInlineImage associated with it.
virtual char* GetError |
( |
void |
| ) |
|
|
virtual |
Returns the error message found during reading image file.
virtual unsigned char* GetRasterPosition |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
virtual |
Returns a pointer to the memory location corresponding to the given X,Y position within the image
- Parameters
-
x | X raster position |
y | Y raster position |
virtual void GlTextureCompression |
( |
bool |
set | ) |
|
|
virtual |
Enable or disable Open GL texture compression for this image
- Parameters
-
set | Whether or not Open GL texture compression is enabled |
virtual bool GlTextureCompression |
( |
| ) |
|
|
virtual |
- Returns
- Whether or not Open GL texture compression is enabled
virtual int Height |
( |
void |
| ) |
|
|
virtual |
- Returns
- the height of the image.
virtual unsigned char* ImageData |
( |
void |
| ) |
|
|
virtual |
- Returns
- A pointer to the 2D image data
virtual void Initialize |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
pixelSize |
|
) |
| |
|
protectedvirtual |
Helper routine used by constructor. Allocates pixel memory and sets the texture width, height and pixel size
- Parameters
-
width | Width of the image |
height | Height of the image |
pixelSize | The size in bytes of each pixel |
static List_c& InstanceList |
( |
| ) |
|
|
static |
All images get added to the InstanceList
Use this Mutex when accessing the InstanceList
bool IsAllowNPOTTextures |
( |
void |
| ) |
const |
Determine if non-power of two (NPOT) textures are allowed for this image.
- Returns
- true if non-power of two (NPOT) textures are allowed.
static bool IsDuplicate |
( |
Image * |
image, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
components, |
|
|
unsigned long |
crcVal, |
|
|
bool |
glTexCompress |
|
) |
| |
|
static |
Determines if an image #1 is the same a notional image based on the following criteria
- Parameters
-
image | Image #1 |
width | Width of notional image |
height | Height of notional image |
components | Number of components in the notional image |
crcVal | 32 bit CRC of notional image |
glTexCompress | GlTextureCompresssion setting for the image |
- Returns
- True if they are equal
bool IsReleaseImageDataEnabled |
( |
| ) |
|
virtual bool LoadInlineImageData |
( |
| ) |
|
|
virtual |
Allocates the local rgb buffer from the glsInlineImage for this image.
- Returns
- true if successful, false on failure (e.g. this image doesn't have a glsInlineImage associated with it.)
virtual void MipMap |
( |
bool |
set | ) |
|
|
virtual |
Enable or disable mipmaps for this image
- Parameters
-
set | Whether or not mipmaps are enabled |
Implements IFontImage.
- Returns
- Whether or not mipmaps are enabled
- Returns
- the number of simultanious users of this image
virtual void operator= |
( |
Image & |
im | ) |
|
|
virtual |
Overloaded operator for copying Image objects.
virtual int operator== |
( |
Image & |
im | ) |
|
|
virtual |
Equality operator. Determines if two images are equal
- Parameters
-
- Returns
- boolean result
virtual int PixelFormat |
( |
void |
| ) |
|
|
virtual |
Returns the pixel format for this image
- Returns
- The internal pixel format for this image
Implements IFontImage.
virtual void PixelFormat |
( |
int |
format | ) |
|
|
virtual |
Sets the pixel format for this image and also the pixel size as determined from the format. Eg. GL_RGBA has a pixel size of 4.
- Parameters
-
format | The new internal pixel format for this image |
virtual char* PixelFormatString |
( |
void |
| ) |
|
|
virtual |
- Returns
- The OpenGL enumerator for the pixel format for this image as a string. Used for inline texture generation
virtual int PixelSize |
( |
void |
| ) |
|
|
virtual |
- Returns
- The size of a pixel in this image in bytes
virtual void ReplaceImage |
( |
unsigned char * |
imageData | ) |
|
|
virtual |
Replaces the current image with the specified. The new image must be the same _texWidth, _texHeight, and _pixelSize as the current image
virtual bool ReplaceImage |
( |
unsigned char * |
imageData, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
pixelSize |
|
) |
| |
|
virtual |
Replaces the current image with the specified.
- Parameters
-
imageData | buffer containing the new image data |
width | new Width of the image. Must be a power of two (2^n). |
height | new Height of the image. Must be a power of two (2^n). |
pixelSize | The size in bytes of each pixel |
- Returns
- true if successful, false if the operation is unsupported or there was an error.
virtual void ScaleTexture |
( |
void |
| ) |
|
|
virtual |
Scale the texture to the nearest power of two
virtual void ScaleToPowerOfTwo |
( |
void |
| ) |
|
|
virtual |
Scales the image up to the nearest power of two in each dimension
virtual void SetAsCurrentTexture |
( |
void |
| ) |
|
|
virtual |
Takes the image and creates a 2D Decal texture map. (Not Implemented)
virtual void SetError |
( |
char * |
errorMessage | ) |
|
|
virtual |
Sets the error message.
- Parameters
-
errorMessage | String containing error message. |
virtual void SetPixel |
( |
int |
x, |
|
|
int |
y, |
|
|
float |
color[] |
|
) |
| |
|
virtual |
Set the value of a secific pixel in the rbg buffer.
- Parameters
-
x | X position of the pixel |
y | Y position of the pixel |
color | Color of the pixel |
void SetReleaseImageDataEnabled |
( |
bool |
enable | ) |
|
Determines whether this image will release its image data from main memory when it is not needed.
When enabled (true), the the Image will release the main memory copy of the data when it is not needed in order to save memory. This flag is enabled by default and should be disabled in situations such as when the ImageData for this Image cannot be re-created from permanent storage.
- Note
- The default value is determined by disti::GetReleaseImageDataDefault().
- Parameters
-
enable | Whether release of image data is enabled. |
- See also
- IsReleaseImageDataEnabled()
-
disti::SetReleaseImageDataDefault()
- Note
- The static methods SetUnloadImageDataEnabled() and IsUnloadImageDataEnabled() from Image and Image::InstanceListEntry were removed to disambiguate between the per-instance setting and the global setting. Code that was calling Image::SetUnloadImageDataEnabled() to set the default flag for all instances should now call disti::SetReleaseImageDataDefault(). Code that was calling Image::InstanceListEntry::SetUnloadImageDataEnabled() to set the flag for only one instance should call this method.
virtual void SetTexWidthHeight |
( |
void |
| ) |
|
|
protectedvirtual |
Set the Image _texWidth, _texHeight, _texWidth, _texCoord[0], and _texCoord[1]. Width and height must be set before calling this function.
virtual int Size |
( |
void |
| ) |
|
|
virtual |
- Returns
- the memory size of the image in bytes
virtual float TextureCoordX |
( |
void |
| ) |
|
|
virtual |
- Returns
- the X position of the texture coordinate used for the image.
virtual float TextureCoordY |
( |
void |
| ) |
|
|
virtual |
- Returns
- the Y position of the texture coordinate used for the image.
virtual unsigned int TextureHandle |
( |
| ) |
const |
|
inlinevirtual |
- Returns
- the OpenGL texture handle of this texture instance
virtual bool TextureHandleValid |
( |
| ) |
|
|
virtual |
- Returns
- true if the internal texture handle is valid
virtual int TextureHeight |
( |
void |
| ) |
|
|
virtual |
- Returns
- the texture height of the image file. This is the power of 2 size greater than or equal the size of the image.
virtual int TextureWidth |
( |
void |
| ) |
|
|
virtual |
- Returns
- the texture width of the image file. This is the power of 2 size greater than or equal to the size of the image.
Unload RGB and mipmap data to save memory
virtual int Width |
( |
void |
| ) |
|
|
virtual |
- Returns
- the width of the image.
If true, this texture is not scaled to power of two.
CRC value used to determine if two images are the same
Error found reading image file flag.
Error message in string format.
bool _globalMipMapEnabled |
|
static |
Determines the default value for _mipMap, and does not do mip mapping if false
bool _glTextureCompression |
|
protected |
Indicates if GL Texture compression is enabled for this image
bool _glTextureCompressionSupported |
|
staticprotected |
Indicates if GL Texture compression is supported on the Machine that this program is running on.
Actual height of image in pixels.
True if this image should use mip mapping
Pointers to the smaller versions of _rgbBuf
Count of number of objects that reference this one
Pixel format for the image
true to allow image data for image to be unloaded from main memory else false
Indicates the images has been changed and needs to be re-bound
Pointer to the image data for this image.
Inline image data for this image, if applicable.
Texture coordinates of upper right corner of image. This will be (1.0,1.0) for a square power of two image
Texture height (power of 2) of the image in pixels.
unsigned int _textureHandle |
|
protected |
The texture handle of the image.
Texture width (power of 2) of the image in pixels.
Actual width of image in pixels.
The documentation for this class was generated from the following file: