libnds
Data Structures | Typedefs | Functions
image.h File Reference

An image abstraction for working with image data. More...

#include <nds/arm9/video.h>

Data Structures

struct  RGB_24
 Holds a red green blue triplet. More...
 
struct  sImage
 A generic image structure. More...
 

Typedefs

typedef struct RGB_24 RGB_24
 Holds a red green blue triplet.
 
typedef struct sImage sImage
 A generic image structure.
 

Functions

bool image24to16 (sImage *img)
 Destructively converts a 24-bit image to 16-bit. More...
 
bool image8to16 (sImage *img)
 Destructively converts an 8-bit image to 16 bit setting the alpha bit. More...
 
bool image8to16trans (sImage *img, u8 transparentColor)
 Destructively converts an 8-bit image to 16-bit with alpha bit cleared for the supplied palette index. More...
 
void imageDestroy (sImage *img)
 Frees the image data. More...
 
bool imageTileData (sImage *img)
 Tiles 8-bit image data into a sequence of 8x8 tiles. More...
 

Detailed Description

An image abstraction for working with image data.

Image data buffers must be allocated using malloc() rather than pointing to stack data, as the conversion routines will free() the argument's image buffer and allocate a new block for the replacement data.

As such, any loader implemented utilizing this structure must use malloc() to allocate the image buffer.

Function Documentation

◆ image24to16()

bool image24to16 ( sImage img)

Destructively converts a 24-bit image to 16-bit.

Parameters
imgPointer to the image to manipulate.
Returns
true on success, false on failure.

◆ image8to16()

bool image8to16 ( sImage img)

Destructively converts an 8-bit image to 16 bit setting the alpha bit.

Parameters
imgPointer to the image to manipulate.
Returns
true on success, false on failure.

◆ image8to16trans()

bool image8to16trans ( sImage img,
u8  transparentColor 
)

Destructively converts an 8-bit image to 16-bit with alpha bit cleared for the supplied palette index.

Parameters
imgPointer to the image to manipulate.
transparentColorColor indexes equal to this value will have the alpha bit clear
Returns
true on success, false on failure.

◆ imageDestroy()

void imageDestroy ( sImage img)

Frees the image data.

Only call if the image data was returned from an image loader.

Parameters
imgPointer to the image to manipulate.

◆ imageTileData()

bool imageTileData ( sImage img)

Tiles 8-bit image data into a sequence of 8x8 tiles.

Parameters
imgPointer to the image to manipulate.
Returns
true on success, false on failure.