HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_RasterTypes.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: IMG_Raster.h ( IMG Library, C++)
7  *
8  * COMMENTS:
9  * IMG_Raster is the utility class for containing a 2D raster.
10  *
11  * UT_DeepRaster contains 16 bit channels and is useful for maintaining
12  * extra color precision at low alpha values. Composite operations are
13  * provided in the IMG_Raster class for compositing both IMG_Raster's and
14  * IMG_DeepRaster's.
15  */
16 
17 #ifndef __IMG_RasterTypes__
18 #define __IMG_RasterTypes__
19 
20 #include <SYS/SYS_Types.h>
21 
22 template<typename T> struct UT_RGBAT;
23 typedef UT_RGBAT<uint8> UT_RGBA;
25 
26 #define IMG_SMALL_IMAGE 100 // Default size for scaled loading
27 
28 #define IMG_COMPOSITE_CLEAR 0x100
29 
52 };
53 
68 };
69 
71  IMG_SCALE_NONE = 0, // No scaling of raster
72  IMG_SCALE_SIZE, // Re-size given a specific filter
73  IMG_SCALE_FIT // scale IMG_Raster to loaded image.
74 };
75 
85 };
86 
87 //
88 // You can or these together and pass as second argument to setEdgeChannel
89 //
95 };
96 
97 typedef void (*IMG_Compositebit_8_8) (UT_RGBA *dest, UT_RGBA *op, int len );
98 typedef void (*IMG_Compositebit_8_16) (UT_RGBA *dest, UT_BIG_RGBA *op, int len );
99 typedef void (*IMG_Compositebit_16_16)(UT_BIG_RGBA *dest, UT_BIG_RGBA *op, int len );
100 typedef void (*IMG_Compositebit_16_8) (UT_BIG_RGBA *dest, UT_RGBA *op, int len );
101 
102 typedef void (*IMG_UnaryOp) (UT_RGBA *pixel); // Remove this.
103 
104 typedef void (*IMG_UnaryOp16)(UT_BIG_RGBA *pixel, int length);
105 typedef void (*IMG_UnaryOp8) (UT_RGBA *pixel, int length);
106 
107 //==========================================================================
108 
109 #define CHANNEL_BITS 8
110 #define BIG_CHANNEL_BITS 16
111 #define HUE_CHANNEL_BITS 15
112 #define SAT_CHANNEL_BITS 15
113 #define VAL_CHANNEL_BITS 16
114 #define ALP_CHANNEL_BITS 16 // HSVA alpha
115 
116 #define CHANNEL_MAX 0xFF
117 #define BIG_CHANNEL_MAX 0xFFFF
118 #define HUE_CHANNEL_MAX 0x7FFF
119 #define SAT_CHANNEL_MAX 0x7FFF
120 #define VAL_CHANNEL_MAX 0xFFFF
121 #define ALP_CHANNEL_MAX 0xFFFF // HSVA alpha
122 
123 #define POINT_FIVE 0x80
124 #define BIG_POINT_FIVE 0x8000
125 
126 #define CHANNEL_SHIFT (BIG_CHANNEL_BITS - CHANNEL_BITS)
127 
128 // HSV to SMALL_CHANNEL
129 #define HUE_SHIFT (HUE_CHANNEL_BITS - CHANNEL_BITS)
130 #define SAT_SHIFT (SAT_CHANNEL_BITS - CHANNEL_BITS)
131 #define VAL_SHIFT (VAL_CHANNEL_BITS - CHANNEL_BITS)
132 #define HUE_POINT_FIVE (1 << (HUE_SHIFT - 1))
133 #define SAT_POINT_FIVE (1 << (SAT_SHIFT - 1))
134 #define VAL_POINT_FIVE (1 << (VAL_SHIFT - 1))
135 #define HUE_TO_SMALL_CHANNEL(v) (((v) + HUE_POINT_FIVE) >> HUE_SHIFT)
136 #define SAT_TO_SMALL_CHANNEL(v) (((v) + SAT_POINT_FIVE) >> SAT_SHIFT)
137 #define VAL_TO_SMALL_CHANNEL(v) (((v) + VAL_POINT_FIVE) >> VAL_SHIFT)
138 
139 // HSV to BIG_CHANNEL
140 #define BIG_HUE_SHIFT (BIG_CHANNEL_BITS - HUE_CHANNEL_BITS)
141 #define BIG_SAT_SHIFT (BIG_CHANNEL_BITS - SAT_CHANNEL_BITS)
142 #define BIG_VAL_SHIFT (BIG_CHANNEL_BITS - VAL_CHANNEL_BITS)
143 #define HUE_ROUND(v) ((v) >>((HUE_CHANNEL_BITS<<1)-BIG_CHANNEL_BITS))
144 #define SAT_ROUND(v) ((v) >>((SAT_CHANNEL_BITS<<1)-BIG_CHANNEL_BITS))
145 #define VAL_ROUND(v) ((v) >>((VAL_CHANNEL_BITS<<1)-BIG_CHANNEL_BITS))
146 #define HUE_TO_BIG_CHANNEL(v) (((v) << BIG_HUE_SHIFT) | HUE_ROUND(v))
147 #define SAT_TO_BIG_CHANNEL(v) (((v) << BIG_SAT_SHIFT) | SAT_ROUND(v))
148 #define VAL_TO_BIG_CHANNEL(v) (((v) << BIG_VAL_SHIFT) | VAL_ROUND(v))
149 
150 #define BIG_TO_SMALL_CHANNEL(v) ((v) >> CHANNEL_SHIFT)
151 #define SMALL_TO_BIG_CHANNEL(v) ((v) << CHANNEL_SHIFT | (v))
152 
153 #define MONO_WEIGHTR 76 // .299
154 #define MONO_WEIGHTG 151 // .587
155 #define MONO_WEIGHTB 29 // .114
156 
157 #define NTSC_LUM(r, g, b) ((((r) * MONO_WEIGHTR) \
158  + ((g) * MONO_WEIGHTG) \
159  + ((b) * MONO_WEIGHTB)) >> 8)
160 
161 #endif
void(* IMG_UnaryOp8)(UT_RGBA *pixel, int length)
IMG_EdgeOptions
void
Definition: png.h:1083
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
void(* IMG_UnaryOp)(UT_RGBA *pixel)
UT_RGBAT< uint8 > UT_RGBA
void(* IMG_Compositebit_16_16)(UT_BIG_RGBA *dest, UT_BIG_RGBA *op, int len)
void(* IMG_UnaryOp16)(UT_BIG_RGBA *pixel, int length)
IMG_ScaleOp
UT_RGBAT< uint16 > UT_BIG_RGBA
#define IMG_COMPOSITE_CLEAR
IMG_Channel
IMG_CompositeOp
void(* IMG_Compositebit_16_8)(UT_BIG_RGBA *dest, UT_RGBA *op, int len)
void(* IMG_Compositebit_8_8)(UT_RGBA *dest, UT_RGBA *op, int len)
IMG_FilterOp
void(* IMG_Compositebit_8_16)(UT_RGBA *dest, UT_BIG_RGBA *op, int len)