Root/
Source at commit 1078 created 13 years 1 month ago. By azimutz, Put back message removed by mistake on r1061. | |
---|---|
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 | ␊ |
15 | char *getVBEInfoString();␊ |
16 | ␊ |
17 | ␊ |
18 | typedef union {␊ |
19 | struct {␊ |
20 | uint8_t b;␊ |
21 | uint8_t g;␊ |
22 | uint8_t r;␊ |
23 | uint8_t a;␊ |
24 | } ch;␊ |
25 | uint8_t channel[4];␊ |
26 | uint32_t value;␊ |
27 | } pixel_t;␊ |
28 | ␊ |
29 | typedef struct {␊ |
30 | uint16_t␉height;␊ |
31 | uint16_t␉width;␊ |
32 | pixel_t*␉pixels;␊ |
33 | } pixmap_t;␊ |
34 | ␊ |
35 | typedef struct {␊ |
36 | uint32_t x;␊ |
37 | uint32_t y;␊ |
38 | } position_t;␊ |
39 | ␊ |
40 | // Blends the given pixmap into the given background at the given position␊ |
41 | // Uses the alpha channels to blend, and preserves the final alpha (so the␊ |
42 | // resultant pixmap can be blended again with another background).␊ |
43 | // ported from www.stereopsis.com/doubleblend.html␊ |
44 | void blend( const pixmap_t *blendThis, // Source image␊ |
45 | pixmap_t *blendInto, // Dest image␊ |
46 | const position_t position); // Where to place the source image␊ |
47 | // Returns the topleft co-ordinate where if you put the 'toCenter' pixmap,␊ |
48 | // it is centered in the background.␊ |
49 | position_t centeredIn( const pixmap_t *background, const pixmap_t *toCenter );␊ |
50 | ␊ |
51 | // Returns the topleft co-ordinate where if you put the given pixmap, its␊ |
52 | // center will coincide with the th given center.␊ |
53 | position_t centeredAt( const pixmap_t *pixmap, const position_t center );␊ |
54 | ␊ |
55 | // Utility function returns a position_t struct given the x and y coords as uint16␊ |
56 | position_t pos(const uint16_t x, const uint16_t y);␊ |
57 | ␊ |
58 | // Flips the R and B components of all pixels in the given pixmap␊ |
59 | void flipRB(pixmap_t *p);␊ |
60 | ␊ |
61 | // Utility function to get pixel at (x,y) in a pixmap␊ |
62 | #define pixel(p,x,y) ((p)->pixels[(x) + (y) * (p)->width])␊ |
63 | ␊ |
64 | #endif//GRAPHIC_UTILS_H␊ |
65 |