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 "libsaio.h"␊ |
13 | ␊ |
14 | ␊ |
15 | char *getVBEInfoString(void);␊ |
16 | void printVBEModeInfo(void);␊ |
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 | ␊ |
48 | ␊ |
49 | //void blendFadeIn( const pixmap_t *blendThis, // Source image␊ |
50 | //␉␉␉␉ pixmap_t *blendInto, // Dest image␊ |
51 | //␉␉␉␉ const position_t position) // Where to place the source image␊ |
52 | ␊ |
53 | // Returns the topleft co-ordinate where if you put the 'toCenter' pixmap,␊ |
54 | // it is centered in the background.␊ |
55 | position_t centeredIn( const pixmap_t *background, const pixmap_t *toCenter );␊ |
56 | ␊ |
57 | // Returns the topleft co-ordinate where if you put the given pixmap, its␊ |
58 | // center will coincide with the th given center.␊ |
59 | position_t centeredAt( const pixmap_t *pixmap, const position_t center );␊ |
60 | ␊ |
61 | // Utility function returns a position_t struct given the x and y coords as uint16␊ |
62 | position_t pos(const uint16_t x, const uint16_t y);␊ |
63 | ␊ |
64 | // Flips the R and B components of all pixels in the given pixmap␊ |
65 | void flipRB(pixmap_t *p);␊ |
66 | ␊ |
67 | int getNumberArrayFromProperty( const char * propKey,␊ |
68 | unsigned long numbers[],␊ |
69 | unsigned long maxArrayCount );␊ |
70 | ␊ |
71 | ␊ |
72 | int setVESAGraphicsMode( unsigned short width, unsigned short height, unsigned char bitsPerPixel);␊ |
73 | ␊ |
74 | void getGraphicModeParams(unsigned long params[]);␊ |
75 | char *getVBEModeInfoString(void);␊ |
76 | ␊ |
77 | void blendImage(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data);␊ |
78 | ␊ |
79 | void drawCheckerBoard(void);␊ |
80 | ␊ |
81 | int␊ |
82 | convertImage( unsigned short width,␊ |
83 | unsigned short height,␊ |
84 | const unsigned char *imageData,␊ |
85 | unsigned char **newImageData );␊ |
86 | ␊ |
87 | void drawDataRectangle( unsigned short x,␊ |
88 | unsigned short y,␊ |
89 | unsigned short width,␊ |
90 | unsigned short height,␊ |
91 | unsigned char * data );␊ |
92 | ␊ |
93 | void drawColorRectangle( unsigned short x,␊ |
94 | unsigned short y,␊ |
95 | unsigned short width,␊ |
96 | unsigned short height,␊ |
97 | unsigned char colorIndex );␊ |
98 | ␊ |
99 | ␊ |
100 | void setVideoMode(int mode);␊ |
101 | ␊ |
102 | char * decodeRLE( const void * rleData, int rleBlocks, int outBytes );␊ |
103 | ␊ |
104 | ␊ |
105 | ␊ |
106 | // Utility function to get pixel at (x,y) in a pixmap␊ |
107 | #define pixel(p,x,y) ((p)->pixels[(x) + (y) * (p)->width])␊ |
108 | ␊ |
109 | #endif//GRAPHIC_UTILS_H␊ |
110 | |