TGraphicSurface Class Reference

This structure defines an surface in device format. More...

#include <Images.h>

Inheritance diagram for TGraphicSurface:

Inheritance graph
[legend]
Collaboration diagram for TGraphicSurface:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TGraphicSurface (void)
 Constructor.
 ~TGraphicSurface (void)
 Destructor.
 TGraphicSurface (const TGraphicSurface &orig)
 fake copy constructor
void operator= (const TGraphicSurface &orig)
 fake assignment operator
BOOL Create (DWORD width, DWORD height, EnumGraphicFormat format)
 Creates new image.
BOOL Create (const TSurfaceDesc &desc)
 Creates surface.
void Unload (void)
 Unload image.
void Clone (TGraphicSurface **dest) const
 Copy this image to new one.
void Set (const TGraphicSurface &orig)
 Set(copy) image in parameter to this image.
BOOL IsLoaded (void) const
 Determines whether any image is loaded inside object.
BOOL IsCompressed (void) const
 Determines whether image has compressed device format (e.g.
BOOL IsRGB (void) const
 Determines whether image has RGB-type device format (e.g.
TSurfaceDesc GetSurfDesc (void) const
 Return surface description.
DWORD GetWidth (void) const
 Returns width of image in pixels.
DWORD GetHeight (void) const
 Returns height of image in pixels.
EnumGraphicFormat GetPixelFormat (void) const
 Returns pixel format of image.
DWORD GetPixelSize (void) const
 Returns size of one pixel in bytes.
DWORD GetSize (void) const
 Returns image size in bytes (size of image data - see GetImageData() method).
DWORD GetRowSize (void) const
 Returns size of one row in bytes (also known as pitch).
const TBufferGetImageData (void) const
 Returns pointer to image data.
TBufferGetImageData (void)
 Returns pointer to image data.
BOOL SetImageData (const TBuffer &data)
 Sets data to image (data are copied).

Detailed Description

This structure defines an surface in device format.

This is software equivalent for TRendererSurface.

Image must be loaded before you use it - see TGraphicSurface::IsLoaded() method. You may load image only by creating it. (Or load it from file if TGraphicSurface is part of TGraphicTexture object)

Actually it supports only these formats: GRAPH_FMT_X8R8G8B8 GRAPH_FMT_A8R8G8B8 GRAPH_FMT_L8 GRAPH_FMT_A8 GRAPH_FMT_R5G6B5 GRAPH_FMT_X1R5G5B5

GRAPH_FMT_DXT1 GRAPH_FMT_DXT2 GRAPH_FMT_DXT3 GRAPH_FMT_DXT4 GRAPH_FMT_DXT5

Definition at line 49 of file Images.h.


Constructor & Destructor Documentation

TGraphicSurface::TGraphicSurface void   ) 
 

Constructor.

Creates empty (unloaded) image - see IsLoaded() method. Before using you must create surface with method Create !!!.

Definition at line 24 of file Images.cpp.

References FALSE, GRAPH_FMT_UNKNOWN, TSurfaceDesc::m_height, TSurfaceDesc::m_pixelFormat, and TSurfaceDesc::m_width.

TGraphicSurface::~TGraphicSurface void   ) 
 

Destructor.

Destroy image.

Definition at line 42 of file Images.cpp.

References Unload().

Here is the call graph for this function:

TGraphicSurface::TGraphicSurface const TGraphicSurface orig  ) 
 

fake copy constructor


Member Function Documentation

void TGraphicSurface::Clone TGraphicSurface **  dest  )  const
 

Copy this image to new one.

Before calling memory allocated via pointer should be deallocated, because this method sets to pointer new memory adress!!!

Warning:
This method allocates memory which must be deallocated by caller.
Parameters:
dest [out] address of pointer to store result

Definition at line 230 of file Images.cpp.

References DBGASSERT, and Set().

Here is the call graph for this function:

BOOL TGraphicSurface::Create const TSurfaceDesc desc  )  [inline]
 

Creates surface.

Parameters:
desc [in] surface description

Definition at line 78 of file Images.h.

References Create(), TSurfaceDesc::m_height, TSurfaceDesc::m_pixelFormat, and TSurfaceDesc::m_width.

Here is the call graph for this function:

BOOL TGraphicSurface::Create DWORD  width,
DWORD  height,
EnumGraphicFormat  format
 

Creates new image.

Old image is always destroyed. This method can enlarge surface size for compressed formats if size is smaller than block size. For example for 2x2 DXT1 format method creates 4x4 DXT1 surface. But always original size is stored!!!!
Previous image is destroyed (if it was exist).

When you create RGB image surface via this method pitch is always equal to width*pixelSize (no aligned bytes between rows). Thus image data are continuously stored inside data buffer.

Parameters:
width [in]width of new image
height [in]height of new image
format [in]format of new image
Return values:
TRUE image was created successfully
FALSE creation failed

Definition at line 64 of file Images.cpp.

References DBGTEXTF, FALSE, GRAPH_FMT_A8, GRAPH_FMT_A8R8G8B8, GRAPH_FMT_DXT1, GRAPH_FMT_DXT2, GRAPH_FMT_DXT3, GRAPH_FMT_DXT4, GRAPH_FMT_DXT5, GRAPH_FMT_L8, GRAPH_FMT_R5G6B5, GRAPH_FMT_X1R5G5B5, GRAPH_FMT_X8R8G8B8, TSurfaceDesc::m_height, TSurfaceDesc::m_pixelFormat, TSurfaceDesc::m_width, TRUE, and Unload().

Referenced by Create(), and TGraphicTexture::Create().

Here is the call graph for this function:

DWORD TGraphicSurface::GetHeight void   )  const [inline]
 

Returns height of image in pixels.

Definition at line 105 of file Images.h.

References TSurfaceDesc::m_height.

TBuffer* TGraphicSurface::GetImageData void   )  [inline]
 

Returns pointer to image data.

For getting size of this data call GetSize(void). If image contains no data NULL is returned, also GetSize() returns 0.

Definition at line 136 of file Images.h.

const TBuffer* TGraphicSurface::GetImageData void   )  const [inline]
 

Returns pointer to image data.

For getting size of this data call GetSize(void). If image contains no data NULL is returned, also GetSize() returns 0.

Definition at line 131 of file Images.h.

EnumGraphicFormat TGraphicSurface::GetPixelFormat void   )  const [inline]
 

Returns pixel format of image.

Definition at line 109 of file Images.h.

References TSurfaceDesc::m_pixelFormat.

DWORD TGraphicSurface::GetPixelSize void   )  const [inline]
 

Returns size of one pixel in bytes.

For compressed formats returns size of one block or format-specified value.

Definition at line 114 of file Images.h.

DWORD TGraphicSurface::GetRowSize void   )  const [inline]
 

Returns size of one row in bytes (also known as pitch).

This is important only for RGB-type images. (See IsRGB(void)). For compressed images pitch is also valid, but has different mean!!! For DXTn formats pitch value is defined as size of 4 rows of surface in bytes, thus in DXTn formats are no additional bits (data are stored continuously)

Definition at line 126 of file Images.h.

DWORD TGraphicSurface::GetSize void   )  const [inline]
 

Returns image size in bytes (size of image data - see GetImageData() method).

Definition at line 118 of file Images.h.

TSurfaceDesc TGraphicSurface::GetSurfDesc void   )  const [inline]
 

Return surface description.

Definition at line 97 of file Images.h.

DWORD TGraphicSurface::GetWidth void   )  const [inline]
 

Returns width of image in pixels.

Definition at line 101 of file Images.h.

References TSurfaceDesc::m_width.

BOOL TGraphicSurface::IsCompressed void   )  const [inline]
 

Determines whether image has compressed device format (e.g.

DXTn)

Definition at line 89 of file Images.h.

BOOL TGraphicSurface::IsLoaded void   )  const [inline]
 

Determines whether any image is loaded inside object.

Definition at line 85 of file Images.h.

Referenced by Set().

BOOL TGraphicSurface::IsRGB void   )  const [inline]
 

Determines whether image has RGB-type device format (e.g.

X8R8G8B8)

Definition at line 93 of file Images.h.

void TGraphicSurface::operator= const TGraphicSurface orig  ) 
 

fake assignment operator

void TGraphicSurface::Set const TGraphicSurface orig  ) 
 

Set(copy) image in parameter to this image.

Parameters:
orig [in]original surface - must be loaded (see IsLoaded)

Definition at line 243 of file Images.cpp.

References IsLoaded(), and Unload().

Referenced by Clone().

Here is the call graph for this function:

BOOL TGraphicSurface::SetImageData const TBuffer data  ) 
 

Sets data to image (data are copied).

Data in buffer must have the same size as data in image.

Parameters:
data [in] buffer with data - data size in bytes must be equal to TBuffer::GetSize() value.
Returns:
TRUE if data size was right, FALSE otherwise.

Definition at line 270 of file Images.cpp.

References DBGTEXTF, FALSE, and TBuffer::GetSize().

Here is the call graph for this function:

void TGraphicSurface::Unload void   ) 
 

Unload image.

Definition at line 207 of file Images.cpp.

References FALSE, GRAPH_FMT_UNKNOWN, TSurfaceDesc::m_height, TSurfaceDesc::m_pixelFormat, and TSurfaceDesc::m_width.

Referenced by Create(), Set(), and ~TGraphicSurface().


The documentation for this class was generated from the following files:
Generated on Wed Nov 28 22:42:38 2007 for Joy4D by  doxygen 1.4.6-NO