Class Reference

DK_Image

DK_Image is a data class that handles images.

Constructor

DK_Image();
DK_Image(const DK_CanvasRect &rect);
Creates an empty DK_Image object. If the rect argument is passed, memory is allocated for an image of the size defined by rect. DK_CanvasRect is defined in DK_Rect.h.

setRect

void setRect(DK_CanvasRect const &rect);
Creates a new image of the size specified by rect.

getRect

DK_CanvasRect getRect() const;
Returns the position and size of the DK_Image object in canvas coordinates.

getHeight

int getHeight() const;
Returns the height of the DK_Image object in pixels.

getWidth

int getWidth() const;
Returns the width of the DK_Image object in pixels.

getDataArray

DK_PIXEL_ABGR **getDataArray(void);
Returns a pointer to the data as an array. This lets you access your data in loops like the following:

DK_PIXEL_ABGR **imgArray = img->getDataArray();
   for(int r=0; r<img->getHeight(); ++r)
      for(int c=0; c<img->getWidth(); ++c) {
         imgArray[r][c][0] = alpha;
         imgArray[r][c][1] = blue;
         imgArray[r][c][2] = green;
         imgArray[r][c][3] = red;
      }

getDataPtr

DK_PIXEL *getDataPtr(void);
const DK_PIXEL *getDataPtr() const;
Returns a pointer to the image data.

getLine

DK_PIXEL *getLine(int line);
const DK_PIXEL *getLine(int line) const;
Returns a pointer to the specified line (row of pixels) in the image data. If the specified line is outside the data area, NULL is returned.

getPixel

DK_PIXEL *getPixel(DK_IVector2 &pixel);
const DK_PIXEL *getPixel(DK_IVector2 &pixel)
                                          const;
Returns a pointer to the specified pixel in the image data. If the
specified pixel is outside the data area, NULL is returned.

read

Boolval read(char const *filename);
Retrieves the image stored in the specified file into the DK_Image object. Returns TRUE if successful, FALSE otherwise.

write

Boolval write(char const *filename, 
              char const *format) const;
Writes the DK_Image object to the specified full path and file name, using the specified format. Returns TRUE if successful, FALSE otherwise. Use getFormatCount and getFormat to retrieve a list of available formats. Note that you must set the file name suffix (extension) explicitly.

hasFormat

Boolval hasFormat(char const *format);
Returns TRUE if the specified format is available, FALSE otherwise.

getFormatCount

int getFormatCount();
Returns the number of formats available for storing the DK_Image object.

getFormat

char const *getFormat(int index);
Returns the name of the format specified by index, where index is a number from 0 to getFormatCount() - 1.

copyRect

void copyRect(const DK_CanvasPoint &dstPoint,
              const DK_Image       &srcImage,
              const DK_CanvasRect  &srcRect);
Copies the specified rectangular subregion from the specified source image to the destination point in the DK_Image object. DK_CanvasPoint and DK_CanvasRect are defined in DK_Vector.h.

Constructor
setRect
getRect
getHeight
getWidth
getDataArray
getDataPtr
getLine
getPixel
read
write
hasFormat
getFormatCount
getFormat
copyRect

SOFTIMAGE Eddie 3.5 - 10 JAN 1997