Chameleon

Chameleon Svn Source Tree

Root/branches/azimutz/Chazi/i386/boot2/graphic_utils.h

1 /* Graphic utility functions and data types
2 * Prashant Vaibhav (C) 12/12/2008
3 * Chameleon
4 */
5
6// Everything here is 32 bits per pixel non-premultiplied ARGB format
7//
8
9#ifndef GRAPHIC_UTILS_H
10#define GRAPHIC_UTILS_H
11
12
13
14typedef union {
15 struct {
16 uint8_t b;
17 uint8_t g;
18 uint8_t r;
19 uint8_t a;
20 } ch;
21 uint8_t channel[4];
22 uint32_t value;
23} pixel_t;
24
25typedef struct {
26 uint16_theight;
27 uint16_twidth;
28 pixel_t*pixels;
29} pixmap_t;
30
31typedef struct {
32 uint32_t x;
33 uint32_t y;
34} position_t;
35
36// Blends the given pixmap into the given background at the given position
37// Uses the alpha channels to blend, and preserves the final alpha (so the
38// resultant pixmap can be blended again with another background).
39// ported from www.stereopsis.com/doubleblend.html
40void blend( const pixmap_t *blendThis, // Source image
41 pixmap_t *blendInto, // Dest image
42 const position_t position); // Where to place the source image
43// Returns the topleft co-ordinate where if you put the 'toCenter' pixmap,
44// it is centered in the background.
45position_t centeredIn( const pixmap_t *background, const pixmap_t *toCenter );
46
47// Returns the topleft co-ordinate where if you put the given pixmap, its
48// center will coincide with the th given center.
49position_t centeredAt( const pixmap_t *pixmap, const position_t center );
50
51// Utility function returns a position_t struct given the x and y coords as uint16
52position_t pos(const uint16_t x, const uint16_t y);
53
54// Flips the R and B components of all pixels in the given pixmap
55void flipRB(pixmap_t *p);
56
57// Utility function to get pixel at (x,y) in a pixmap
58#define pixel(p,x,y) ((p)->pixels[(x) + (y) * (p)->width])
59
60#endif//GRAPHIC_UTILS_H
61

Archive Download this file

Revision: 847