bitmap.c File Reference

Bitmap manipulation routines. More...

#include "gfx.h"
#include "cfg/cfg_gfx.h"
#include <cfg/compiler.h>
#include <cpu/attr.h>
#include <gfx/gfx.h>
#include <cfg/macros.h>
#include <cfg/debug.h>
#include <string.h>
#include <gfx/font.h>

Go to the source code of this file.

Defines

#define gfx_clip(dmin, dmax, smin, cmin, cmax)
 Clip destination coordinates inside a clipping range.

Functions

void gfx_bitmapInit (Bitmap *bm, uint8_t *raster, coord_t w, coord_t h)
 Initialize a Bitmap structure with the provided parameters.
void gfx_bitmapClear (Bitmap *bm)
 Clear the whole bitmap surface to the background color.
void gfx_blit (Bitmap *dst, const Rect *rect, const Bitmap *src, coord_t srcx, coord_t srcy)
 Copy a rectangular area of a bitmap on another bitmap.
void gfx_blitRaster (Bitmap *dst, coord_t dxmin, coord_t dymin, const uint8_t *raster, coord_t w, coord_t h, coord_t stride)
 Blit a raster to a Bitmap.
void gfx_blitImage (Bitmap *dst, coord_t dxmin, coord_t dymin, const Image *image)
 Blit an Image to a Bitmap.
void gfx_setClipRect (Bitmap *bm, coord_t minx, coord_t miny, coord_t maxx, coord_t maxy)
 Set the bitmap clipping rectangle to the specified coordinates.

Detailed Description

Bitmap manipulation routines.

Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>
See also:
gfx.h

Definition in file bitmap.c.


Define Documentation

#define gfx_clip ( dmin,
dmax,
smin,
cmin,
cmax   ) 
Value:
do { \
            if ((dmin) < (cmin)) \
            { \
                (smin) += (cmin) - (dmin); \
                (dmin) = (cmin); \
            } \
            (dmax) = MIN((dmax), (cmax)); \
        } while(0)

Clip destination coordinates inside a clipping range.

This macro helps a drawing operation to adjust its destination X and Y coordinates inside the destination clipping range.

The source start coordinate is adjusted as well when destination start clipping occurs.

Definition at line 130 of file bitmap.c.


Function Documentation

void gfx_bitmapClear ( Bitmap bm  ) 

Clear the whole bitmap surface to the background color.

Note:
This function does not update the current pen position.
This function bypasses the current clipping area.

Definition at line 97 of file bitmap.c.

void gfx_bitmapInit ( Bitmap bm,
uint8_t *  raster,
coord_t  w,
coord_t  h 
)

Initialize a Bitmap structure with the provided parameters.

Note:
The pen position is reset to the origin.

Definition at line 62 of file bitmap.c.

void gfx_blit ( Bitmap dst,
const Rect rect,
const Bitmap src,
coord_t  srcx,
coord_t  srcy 
)

Copy a rectangular area of a bitmap on another bitmap.

Blitting is a common copy operation involving two bitmaps. A rectangular area of the source bitmap is copied bit-wise to a different position in the destination bitmap.

Note:
Using the same bitmap for src and dst is unsupported.
Parameters:
dst Bitmap where the operation writes.
rect The (xmin;ymin) coordinates provide the top/left offset for drawing in the destination bitmap. If the source bitmap is larger than the rectangle, drawing is clipped.
src Bitmap containing the source pixels.
srcx Starting X offset in the source bitmap.
srcy Starting Y offset in the source bitmap.

Definition at line 164 of file bitmap.c.

void gfx_blitImage ( Bitmap dst,
coord_t  dxmin,
coord_t  dymin,
const Image image 
)

Blit an Image to a Bitmap.

See also:
gfx_blit()

Definition at line 222 of file bitmap.c.

void gfx_blitRaster ( Bitmap dst,
coord_t  dxmin,
coord_t  dymin,
const uint8_t *  raster,
coord_t  w,
coord_t  h,
coord_t  stride 
)

Blit a raster to a Bitmap.

See also:
gfx_blit()

Definition at line 197 of file bitmap.c.

void gfx_setClipRect ( Bitmap bm,
coord_t  minx,
coord_t  miny,
coord_t  maxx,
coord_t  maxy 
)

Set the bitmap clipping rectangle to the specified coordinates.

All drawing performed on the bitmap will be clipped inside this rectangle.

The clipping rectangle is also used as a bounding box for the logical view of the virtual coordinate system.

Note:
Following the convention used for all other operations, the top-left pixels of the rectangle are included, while the bottom-right pixels are considered outside the clipping region.
See also:
gfx_setViewRect

Definition at line 248 of file bitmap.c.