Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/i386/boot2/graphic_utils.h

Source at commit 214 created 13 years 5 months ago.
By ifabio, update to chameleon trunk 630, and now the pakage folder is the same as blackosx branch, also add Icon "building" into buildpkg script, and add mint theme info into the English localizable.strings.
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#include "boot.h"
13
14
15typedef union {
16 struct {
17 uint8_t b;
18 uint8_t g;
19 uint8_t r;
20 uint8_t a;
21 } ch;
22 uint8_t channel[4];
23 uint32_t value;
24} pixel_t;
25
26typedef struct {
27 uint16_theight;
28 uint16_twidth;
29 pixel_t*pixels;
30} pixmap_t;
31
32typedef struct {
33 uint32_t x;
34 uint32_t y;
35} position_t;
36
37// Blends the given pixmap into the given background at the given position
38// Uses the alpha channels to blend, and preserves the final alpha (so the
39// resultant pixmap can be blended again with another background).
40// ported from www.stereopsis.com/doubleblend.html
41void blend( const pixmap_t *blendThis, // Source image
42 pixmap_t *blendInto, // Dest image
43 const position_t position); // Where to place the source image
44// Returns the topleft co-ordinate where if you put the 'toCenter' pixmap,
45// it is centered in the background.
46position_t centeredIn( const pixmap_t *background, const pixmap_t *toCenter );
47
48// Returns the topleft co-ordinate where if you put the given pixmap, its
49// center will coincide with the th given center.
50position_t centeredAt( const pixmap_t *pixmap, const position_t center );
51
52// Utility function returns a position_t struct given the x and y coords as uint16
53position_t pos(const uint16_t x, const uint16_t y);
54
55// Flips the R and B components of all pixels in the given pixmap
56void flipRB(pixmap_t *p);
57
58// Utility function to get pixel at (x,y) in a pixmap
59#define pixel(p,x,y) ((p)->pixels[(x) + (y) * (p)->width])
60
61#endif//GRAPHIC_UTILS_H
62

Archive Download this file

Revision: 214