1 #ifndef _IOS_IMG_PROCESS
2 #define _IOS_IMG_PROCESS
3 
4 #include "glSDL.h"
5 
6 typedef struct _RGBA {
7   Uint8 red;
8   Uint8 green;
9   Uint8 blue;
10   Uint8 alpha;
11 } RGBA;
12 
13 typedef struct _HSVA {
14   float hue;
15   float saturation;
16   float value;
17   Uint8 alpha;
18 } HSVA;
19 
20 /* Extracting color components from a 32-bit color value
21  * pre: SDL_Locked(surface) */
22 RGBA iim_surface_get_rgba(SDL_Surface *surface, Uint32 x, Uint32 y);
23 
24 /* pre: SDL_Locked(surface) */
25 void iim_surface_set_rgb(SDL_Surface *surface,
26                          Uint32 x, Uint32 y, RGBA c);
27 
28 /* pre: SDL_Locked(surface) */
29 void iim_surface_set_rgba(SDL_Surface *surface,
30                           Uint32 x, Uint32 y, RGBA c);
31 
32 //-- RGB<->HSV conversion
33 
34 //-- RGB, each 0 to 255
35 //-- H = 0.0 to 360.0 (corresponding to 0..360.0 degrees around hexcone)
36 //-- S = 0.0 (shade of gray) to 1.0 (pure color)
37 //-- V = 0.0 (black) to 1.0 (white)
38 
39 //-- Based on C Code in "Computer Graphics -- Principles and Practice,"
40 //-- Foley et al, 1996, pp. 592,593.
41 HSVA iim_rgba2hsva(RGBA c);
42 RGBA iim_hsva2rgba(HSVA c);
43 
44 typedef struct {
45   SDL_Surface *surf;
46   int w;
47   int h;
48   bool isAlpha;
49 } IIM_Surface;
50 
51 IIM_Surface *iim_surface_shift_hue(IIM_Surface *src, float hue_offset);
52 IIM_Surface *iim_surface_set_value(IIM_Surface *src, float value);
53 void iim_surface_convert_to_gray(IIM_Surface *src);
54 
55 IIM_Surface * IIM_Load_DisplayFormat (const char *path);
56 IIM_Surface * IIM_Load_DisplayFormatAlpha (const char *path);
57 void          IIM_Free(IIM_Surface *img);
58 IIM_Surface * IIM_RegisterImg(SDL_Surface *img, bool isAlpha);
59 void          IIM_ReConvertAll(void);
60 
61 #endif
62