
Class Reference
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.
void setRect(DK_CanvasRect const &rect);Creates a new image of the size specified by rect.
DK_CanvasRect getRect() const;Returns the position and size of the DK_Image object in canvas coordinates.
int getHeight() const;Returns the height of the DK_Image object in pixels.
int getWidth() const;Returns the width of the DK_Image object in pixels.
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;
}
DK_PIXEL *getDataPtr(void); const DK_PIXEL *getDataPtr() const;Returns a pointer to the image data.
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.
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 Boolval read(char const *filename);Retrieves the image stored in the specified file into the DK_Image object. Returns TRUE if successful, FALSE otherwise.
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.Boolval hasFormat(char const *format);Returns TRUE if the specified format is available, FALSE otherwise.
int getFormatCount();Returns the number of formats available for storing the DK_Image object.
char const *getFormat(int index);Returns the name of the format specified by index, where index is a number from 0 to getFormatCount() - 1.
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.
