Drag[en]gine Game Engine  1.21
deImage Class Reference

Image resource. More...

#include <deImage.h>

Inheritance diagram for deImage:
deFileResource deResource deObject

Public Types

typedef deTObjectReference< deImageRef
 Type holding strong reference. More...
 
- Public Types inherited from deResource
typedef deTObjectReference< deResourceRef
 Type holding strong reference. More...
 
- Public Types inherited from deObject
typedef deTObjectReference< deObjectRef
 Type holding strong reference. More...
 

Public Member Functions

Management
int GetWidth () const
 Width in pixels. More...
 
int GetHeight () const
 Height in pixels. More...
 
int GetDepth () const
 Depth in pixels. More...
 
int GetComponentCount () const
 Number of components. More...
 
int GetBitCount () const
 Bit count of each component. More...
 
sGrayscale8GetDataGrayscale8 () const
 8-bit Grayscale image data. More...
 
sGrayscale16GetDataGrayscale16 () const
 16-bit Grayscale image data. More...
 
sGrayscale32GetDataGrayscale32 () const
 32-bit Grayscale image data. More...
 
sGrayscaleAlpha8GetDataGrayscaleAlpha8 () const
 8-bit Grayscale-Alpha image data. More...
 
sGrayscaleAlpha16GetDataGrayscaleAlpha16 () const
 16-bit Grayscale-Alpha image data. More...
 
sGrayscaleAlpha32GetDataGrayscaleAlpha32 () const
 32-bit Grayscale-Alpha image data. More...
 
sRGB8GetDataRGB8 () const
 8-bit RGB image data. More...
 
sRGB16GetDataRGB16 () const
 16-bit RGB image data. More...
 
sRGB32GetDataRGB32 () const
 32-bit RGB image data. More...
 
sRGBA8GetDataRGBA8 () const
 8-bit RGBA image data. More...
 
sRGBA16GetDataRGBA16 () const
 16-bit RGBA image data. More...
 
sRGBA32GetDataRGBA32 () const
 32-bit RGBA image data. More...
 
void * GetData () const
 Direct image data pointer. More...
 
void NotifyImageDataChanged ()
 Notify peers image data changed. More...
 
int GetRetainImageDataCount () const
 Retain image data count. More...
 
void RetainImageData ()
 Retain image data. More...
 
void ReleaseImageData ()
 Release image data. More...
 
System Peers
deBaseGraphicImageGetPeerGraphic () const
 Graphic system peer. More...
 
void SetPeerGraphic (deBaseGraphicImage *peer)
 Set graphic system peer. More...
 
Special
void FinalizeConstruction (int width, int height, int depth, int componentCount, int bitCount)
 Finalize construction for internal loading. More...
 
void PeersRetainImageData ()
 Retain image data for peers requiring it. More...
 
- Public Member Functions inherited from deFileResource
deVirtualFileSystemGetVirtualFileSystem () const
 Virtual file system or NULL if build from memory. More...
 
const decStringGetFilename () const
 Filename or empty string if build from memory. More...
 
TIME_SYSTEM GetModificationTime () const
 Modification time used to detect resources changing on disk while loaded. More...
 
void SetModificationTime (TIME_SYSTEM modificationTime)
 Set modification time used to detect resources changing on disk while loaded. More...
 
bool GetAsynchron () const
 Resource is asynchron. More...
 
void SetAsynchron (bool asynchron)
 Set if resource is asynchron. More...
 
bool GetOutdated () const
 
void MarkOutdated ()
 
 deFileResource (deFileResourceManager *resourceManager, deVirtualFileSystem *vfs, const char *filename, TIME_SYSTEM modificationTime)
 Create file resource. More...
 
- Public Member Functions inherited from deResource
deResourceManagerGetResourceManager () const
 Resource manager or NULL if resource is leaking. More...
 
deEngineGetEngine () const
 Game engine object from resource manager. More...
 
deResourceGetLLManagerPrev () const
 Previous resource in the resource manager linked list. More...
 
void SetLLManagerPrev (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
deResourceGetLLManagerNext () const
 Next resource in the resource manager linked list. More...
 
void SetLLManagerNext (deResource *resource)
 Set next resource in the resource manager linked list. More...
 
void MarkLeaking ()
 Marks the resource leaking. More...
 
 deResource (deResourceManager *resourceManager)
 Create resource. More...
 
- Public Member Functions inherited from deObject
int GetRefCount () const
 Reference count. More...
 
void AddReference ()
 Add reference increasing reference count by 1. More...
 
void FreeReference ()
 Decrease reference count by one and delete object if count reaches 0. More...
 
 deObject ()
 Create object with reference count of 1. More...
 

Constructors and Destructors

 deImage (deImageManager *manager, deVirtualFileSystem *vfs, const char *filename, TIME_SYSTEM modificationTime, int width, int height, int depth, int componentCount, int bitCount)
 Create image. More...
 
 deImage (deImageManager *manager, deVirtualFileSystem *vfs, const char *filename, TIME_SYSTEM modificationTime, decXpmImage *image)
 Create image object from XPM image. More...
 
 deImage (deImageManager *manager, deVirtualFileSystem *vfs, const char *filename, TIME_SYSTEM modificationTime)
 Create image for internal loading. More...
 
virtual ~deImage ()
 Clean up resource. More...
 

Additional Inherited Members

- Protected Member Functions inherited from deFileResource
virtual ~deFileResource ()
 Clean up file resource. More...
 
- Protected Member Functions inherited from deResource
virtual ~deResource ()
 Clean up resource. More...
 
- Protected Member Functions inherited from deObject
virtual ~deObject ()
 Clean up object. More...
 

Detailed Description

Image resource.

Image resources are retrieved from the deImageManager bei either loading an image from file or creating a new one. Images loaded from file are treated read-only while created images can be read or write.

If the image is loaded from a file the peers are asked if they need the image data to be retained. If nobody needs the image data retained it is release to reduce memory consumption, which is important on some platforms.

If the peers or any other party needs the image data back in memory it can be retained by calling RetainImageData(). If the image data is no more required ReleaseImageData() has to be called. Whenever nobody needs the image data anymore it is released from memory.

All image parameters except the image data itself can be always accessed safely. Due to the retaining ability the image data itself (all GetData*() calls) can only be accessed when the caller called RetainImageData() earlier. Otherwise GetData*() can return NULL if the image data is currently not retained.

Calling RetainImageData() and ReleaseImageData() uses mutex locking internally to avoid race conditions. Modifications of image data is only allowed by the game scripts during main thread frame updating of the respective scripting module. For accessing the data no locking is required since GetData() is only valid after RetainImageData() finished.

Member Typedef Documentation

◆ Ref

Type holding strong reference.

Constructor & Destructor Documentation

◆ deImage() [1/3]

deImage::deImage ( deImageManager manager,
deVirtualFileSystem vfs,
const char *  filename,
TIME_SYSTEM  modificationTime,
int  width,
int  height,
int  depth,
int  componentCount,
int  bitCount 
)

Create image.

Parameters
[in]managerResource manager to link to.
[in]vfsVirtual file system.
[in]filenameFilename of the image.
[in]widthWidth of the image at least 1.
[in]heightHeight of the image at least 1.
[in]componentsNumber of components (1 to 4 inclusive).
[in]bitCountBit Count of each component (8, 16 or 32).

◆ deImage() [2/3]

deImage::deImage ( deImageManager manager,
deVirtualFileSystem vfs,
const char *  filename,
TIME_SYSTEM  modificationTime,
decXpmImage image 
)

Create image object from XPM image.

Parameters
[in]managerResource manager to link to.
[in]vfsVirtual file system.
[in]filenameFilename of the image.
[in]imageImage data.

◆ deImage() [3/3]

deImage::deImage ( deImageManager manager,
deVirtualFileSystem vfs,
const char *  filename,
TIME_SYSTEM  modificationTime 
)

Create image for internal loading.

Warning
This is a special internal constructor. Never ever call this on your own!

◆ ~deImage()

virtual deImage::~deImage ( )
protectedvirtual

Clean up resource.

Note
Subclasses should set their destructor protected too to avoid users accidently deleting a reference counted object through the object pointer. Only FreeReference() is allowed to delete the object.

Member Function Documentation

◆ FinalizeConstruction()

void deImage::FinalizeConstruction ( int  width,
int  height,
int  depth,
int  componentCount,
int  bitCount 
)

Finalize construction for internal loading.

Warning
This is a special internal constructor. Never ever call this on your own!

◆ GetBitCount()

int deImage::GetBitCount ( ) const
inline

Bit count of each component.

◆ GetComponentCount()

int deImage::GetComponentCount ( ) const
inline

Number of components.

◆ GetData()

void* deImage::GetData ( ) const
inline

Direct image data pointer.

Returns NULL if image data is not retained. To make sure the image data is present call RetainImageData() and ReleaseImageData() when you do not need the data anymore in the future. Calls to RetainImageData() and ReleaseImageData() have to be balanced.

Warning
This is a dangerous function. Use it only if you know what you are doing.

◆ GetDataGrayscale16()

sGrayscale16* deImage::GetDataGrayscale16 ( ) const

16-bit Grayscale image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataGrayscale32()

sGrayscale32* deImage::GetDataGrayscale32 ( ) const

32-bit Grayscale image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataGrayscale8()

sGrayscale8* deImage::GetDataGrayscale8 ( ) const

8-bit Grayscale image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataGrayscaleAlpha16()

sGrayscaleAlpha16* deImage::GetDataGrayscaleAlpha16 ( ) const

16-bit Grayscale-Alpha image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataGrayscaleAlpha32()

sGrayscaleAlpha32* deImage::GetDataGrayscaleAlpha32 ( ) const

32-bit Grayscale-Alpha image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataGrayscaleAlpha8()

sGrayscaleAlpha8* deImage::GetDataGrayscaleAlpha8 ( ) const

8-bit Grayscale-Alpha image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGB16()

sRGB16* deImage::GetDataRGB16 ( ) const

16-bit RGB image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGB32()

sRGB32* deImage::GetDataRGB32 ( ) const

32-bit RGB image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGB8()

sRGB8* deImage::GetDataRGB8 ( ) const

8-bit RGB image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGBA16()

sRGBA16* deImage::GetDataRGBA16 ( ) const

16-bit RGBA image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGBA32()

sRGBA32* deImage::GetDataRGBA32 ( ) const

32-bit RGBA image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDataRGBA8()

sRGBA8* deImage::GetDataRGBA8 ( ) const

8-bit RGBA image data.

See also
GetData().
Exceptions
deeInvalidParamImage format mismatch.

◆ GetDepth()

int deImage::GetDepth ( ) const
inline

Depth in pixels.

◆ GetHeight()

int deImage::GetHeight ( ) const
inline

Height in pixels.

◆ GetPeerGraphic()

deBaseGraphicImage* deImage::GetPeerGraphic ( ) const
inline

Graphic system peer.

◆ GetRetainImageDataCount()

int deImage::GetRetainImageDataCount ( ) const
inline

Retain image data count.

For debug use.

◆ GetWidth()

int deImage::GetWidth ( ) const
inline

Width in pixels.

◆ NotifyImageDataChanged()

void deImage::NotifyImageDataChanged ( )

Notify peers image data changed.

◆ PeersRetainImageData()

void deImage::PeersRetainImageData ( )

Retain image data for peers requiring it.

Warning
This is for internal use only. Do not call on your own.

◆ ReleaseImageData()

void deImage::ReleaseImageData ( )

Release image data.

For use by script modules and engine users requiring to access image data. Decrements retain counter by one. If the counter reaches 0 the image data is unloaded. Otherwise this call has no effect. Calls to RetainImageData() and ReleaseImageData() have to be balanced.

Note
If the image has been created with empty filename the retain counter is set to 1 instead of 0.
This call takes a lock on the image mutex while running.

◆ RetainImageData()

void deImage::RetainImageData ( )

Retain image data.

For use by script modules and engine users requiring to access image data. Increments retain counter by one. If the counter has been 0 the image data is loaded. Otherwise this call has no effect. Call ReleaseImageData() if you do not need the data anymore in the future. Calls to RetainImageData() and ReleaseImageData() have to be balanced.

Note
If the image has been created with empty filename the retain counter is set to 1 instead of 0.
This call takes a lock on the image mutex while running.

◆ SetPeerGraphic()

void deImage::SetPeerGraphic ( deBaseGraphicImage peer)

Set graphic system peer.


The documentation for this class was generated from the following file: