KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Functions
img.h File Reference

Platform-independent image type. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Data Structures

struct  kos_img
 Platform-indpendent image type. More...
 

Macros

#define KOS_IMG_FMT_I(x)   ((x) & 0xffff)
 Read the platform-independent half of the format. More...
 
#define KOS_IMG_FMT_D(x)   (((x) >> 16) & 0xffff)
 Read the platform-specific half of the format. More...
 
#define KOS_IMG_FMT(i, d)   ( ((i) & 0xffff) | (((d) & 0xffff) << 16) )
 Build a format value from a platform-independent half and a platform-specific half of the value. More...
 
#define KOS_IMG_FMT_NONE   0x00
 Undefined or uninitialized format. More...
 
#define KOS_IMG_FMT_RGB888   0x01
 24-bpp interleaved R/G/B bytes. More...
 
#define KOS_IMG_FMT_ARGB8888   0x02
 32-bpp interleaved A/R/G/B bytes. More...
 
#define KOS_IMG_FMT_RGB565   0x03
 16-bpp interleaved R (5 bits), G (6 bits), B (5 bits). More...
 
#define KOS_IMG_FMT_ARGB4444   0x04
 16-bpp interleaved A/R/G/B (4 bits each). More...
 
#define KOS_IMG_FMT_ARGB1555   0x05
 16-bpp interleaved A (1 bit), R (5 bits), G (5 bits), B (5 bits). More...
 
#define KOS_IMG_FMT_PAL4BPP   0x06
 Paletted, 4 bits per pixel (16 colors). More...
 
#define KOS_IMG_FMT_PAL8BPP   0x07
 Paletted, 8 bits per pixel (256 colors). More...
 
#define KOS_IMG_FMT_YUV422   0x08
 8-bit Y (4 bits), U (2 bits), V (2 bits). More...
 
#define KOS_IMG_FMT_BGR565   0x09
 15-bpp interleaved B (5 bits), G (6 bits), R (5 bits). More...
 
#define KOS_IMG_FMT_RGBA8888   0x10
 32-bpp interleaved R/G/B/A bytes. More...
 
#define KOS_IMG_FMT_MASK   0xff
 Basic format mask (not an actual format value). More...
 
#define KOS_IMG_INVERTED_X   0x0100
 X axis of image data is inverted (stored right to left). More...
 
#define KOS_IMG_INVERTED_Y   0x0200
 Y axis of image data is inverted (stored bottom to top). More...
 
#define KOS_IMG_NOT_OWNER   0x0400
 The image is not the owner of the image data buffer. More...
 

Typedefs

typedef struct kos_img kos_img_t
 Platform-indpendent image type. More...
 

Functions

void kos_img_free (kos_img_t *img, int struct_also)
 Free a kos_img_t object. More...
 

Detailed Description

Platform-independent image type.

This file provides a platform-independent image type that is designed to hold any sort of textures or other image data. This type contains a very basic description of the image data (width, height, pixel format), as well as the image data itself.

All of the image-loading libraries in kos-ports should provide a function to load the image data into one of these types.

Author
Dan Potter

Typedef Documentation

typedef struct kos_img kos_img_t

Platform-indpendent image type.

You can use this type for textures or whatever you feel it's appropriate for. "width" and "height" are as you would expect. "format" has a lower-half which is platform-independent and used to basically describe the contained data; the upper-half is platform-dependent and can hold anything (so AND it off if you only want the bottom part).

Note that in some of the more obscure formats (like the paletted formats) the data interpretation may be platform dependent. Thus we also provide a data length field.

Function Documentation

void kos_img_free ( kos_img_t img,
int  struct_also 
)

Free a kos_img_t object.

This function frees the data in a kos_img_t object, returning any memory to the heap as appropriate. Optionally, this can also free the object itself, if required.

Parameters
imgThe image object to free.
struct_alsoSet to non-zero to free the image object itself, as well as any data contained therein.