libtonc: Surface functions

Tonclib

Surface functions
[Video]

Basic video surface API. The TSurface struct and the various functions working on it provide a basic API for working with different types of graphic surfaces, like 16bpp bitmaps, 8bpp bitmaps, but also tiled surfaces.
. More...

Modules

 16bpp bitmap surfaces
 8bpp bitmap surfaces
 4bpp tiled surfaces, column major
 4bpp tiled surfaces, row major

Enumerations

enum  ESurfaceType {
  SRF_NONE = 0, SRF_BMP16 = 1, SRF_BMP8 = 2, SRF_CHR4R = 4,
  SRF_CHR4C = 5, SRF_CHR8 = 6, SRF_ALLOCATED = 0x80
}
 Surface types. More...

Functions

void srf_init (TSurface *srf, enum ESurfaceType type, const void *data, uint width, uint height, uint bpp, u16 *pal)
 Initalize a surface for type formatted graphics.
void srf_pal_copy (const TSurface *dst, const TSurface *src, uint count)
 Copy count colors from src's palette to dst's palette.
void * srf_get_ptr (const TSurface *srf, uint x, uint y)
 Get the byte address of coordinates (x, y) on the surface.
INLINE uint srf_align (uint width, uint bpp)
 Get the word-aligned number of bytes for a scanline.
INLINE void srf_set_ptr (TSurface *srf, const void *ptr)
 Set Data-pointer surface for srf.
INLINE void srf_set_pal (TSurface *srf, const u16 *pal, uint size)
 Set the palette pointer and its size.
INLINE void * _srf_get_ptr (const TSurface *srf, uint x, uint y, uint stride)
 Inline and semi-safe version of srf_get_ptr(). Use with caution.

Detailed Description

Basic video surface API. The TSurface struct and the various functions working on it provide a basic API for working with different types of graphic surfaces, like 16bpp bitmaps, 8bpp bitmaps, but also tiled surfaces.
.

Tonclib's Surface system provides the basic functionality for drawing onto graphic surfaces of different types. This includes

  • bmp16: 16bpp bitmap surfaces
  • bmp8: 8bpp bitmap surfaces.
  • chr4(c/r): 4bpp tiled surfaces. This covers almost all of the GBA graphic modes.

  • SRF_BMP8: 8bpp linear (Mode 4 / affine BGs)
  • SRF_BMP16 16bpp bitmaps (Mode 3/5 / regular BGs to some extent)
  • SRF_CHR4C 4bpp tiles, column-major (Regular tiled BG)
  • SRF_CHR4R 4bpp tiles, row-major (Regular tiled BG, OBJs)

For each of these functions exist for the most important drawing options: plotting, lines and rectangles. For BMP8/BMP16 and to some extent CHR4C, there are blitters as well.


Enumeration Type Documentation

Surface types.

Enumerator:
SRF_NONE  No specific type.
SRF_BMP16  16bpp linear (bitmap/tilemap).
SRF_BMP8  8bpp linear (bitmap/tilemap).
SRF_CHR4R  4bpp tiles, row-major.
SRF_CHR4C  4bpp tiles, column-major.
SRF_CHR8  8bpp tiles, row-major.
SRF_ALLOCATED  Pointers have been allocated.


Function Documentation

INLINE uint srf_align ( uint  width,
uint  bpp 
)

Get the word-aligned number of bytes for a scanline.

Parameters:
width Number of pixels.
bpp Bits per pixel.

void srf_init ( TSurface *  srf,
enum ESurfaceType  type,
const void *  data,
uint  width,
uint  height,
uint  bpp,
u16 *  pal 
)

Initalize a surface for type formatted graphics.

Parameters:
srf Surface to initialize.
type Surface type. See
See also:
ESurfaceType for details.
Parameters:
data Pointer to the surface memory.
width Width of surface.
height Height of surface.
bpp Bitdepth. If type is not 0, this value will be ignored.
pal Pointer to the surface's palette.


Generated on Mon Aug 25 17:03:57 2008 for libtonc by  doxygen 1.5.3