Main Page   Modules   Compound List   File List   Compound Members   File Members  

pixel.h

Go to the documentation of this file.
00001 
00014 /* This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Lesser General Public
00016    License as published by the Free Software Foundation; either
00017    version 2.1 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser General Public
00025    License along with this library; if not, write to the Free Software
00026    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 */
00028 
00029 #ifndef _GAN_PIXEL_H
00030 #define _GAN_PIXEL_H
00031 
00032 #include <gandalf/common/misc_defs.h>
00033 #include <gandalf/common/bit_array.h>
00034 #include <gandalf/linalg/2vector.h>
00035 #include <gandalf/linalg/2vectorf.h>
00036 #include <gandalf/linalg/3vector.h>
00037 #include <gandalf/linalg/3vectorf.h>
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00056 typedef enum { GAN_GREY_LEVEL_IMAGE,       
00057                GAN_GREY_LEVEL_ALPHA_IMAGE, 
00059                GAN_RGB_COLOUR_IMAGE,       
00060                GAN_RGB_COLOUR_ALPHA_IMAGE, 
00062                GAN_VECTOR_FIELD_2D,        
00063                GAN_VECTOR_FIELD_3D }       
00064   Gan_ImageFormat;
00065 
00069 typedef struct Gan_GLAPixel_uc
00070 {
00071    unsigned char I, 
00072                  A; 
00073 } Gan_GLAPixel_uc;
00074 
00078 typedef struct Gan_GLAPixel_s
00079 {
00080    short I, 
00081          A; 
00082 } Gan_GLAPixel_s;
00083 
00087 typedef struct Gan_GLAPixel_us
00088 {
00089    unsigned short I, 
00090                   A; 
00091 } Gan_GLAPixel_us;
00092 
00096 typedef struct Gan_GLAPixel_i
00097 {
00098    int I, 
00099        A; 
00100 } Gan_GLAPixel_i;
00101 
00105 typedef struct Gan_GLAPixel_ui
00106 {
00107    unsigned int I, 
00108                 A; 
00109 } Gan_GLAPixel_ui;
00110 
00114 typedef struct Gan_GLAPixel_f
00115 {
00116    float I, 
00117          A; 
00118 } Gan_GLAPixel_f;
00119 
00123 typedef struct Gan_GLAPixel_d
00124 {
00125    double I, 
00126           A; 
00127 } Gan_GLAPixel_d;
00128 
00132 typedef struct Gan_RGBPixel_uc
00133 {
00134    unsigned char R, 
00135                  G, 
00136                  B; 
00137 } Gan_RGBPixel_uc;
00138 
00142 typedef struct Gan_RGBPixel_s
00143 {
00144    short R, 
00145          G, 
00146          B; 
00147 } Gan_RGBPixel_s;
00148 
00152 typedef struct Gan_RGBPixel_us
00153 {
00154    unsigned short R, 
00155                   G, 
00156                   B; 
00157 } Gan_RGBPixel_us;
00158 
00162 typedef struct Gan_RGBPixel_i
00163 {
00164    int R, 
00165        G, 
00166        B; 
00167 } Gan_RGBPixel_i;
00168 
00172 typedef struct Gan_RGBPixel_ui
00173 {
00174    unsigned int R, 
00175                 G, 
00176                 B; 
00177 } Gan_RGBPixel_ui;
00178 
00182 typedef struct Gan_RGBPixel_f
00183 {
00184    float R, 
00185          G, 
00186          B; 
00187 } Gan_RGBPixel_f;
00188 
00192 typedef struct Gan_RGBPixel_d
00193 {
00194    double R, 
00195           G, 
00196           B; 
00197 } Gan_RGBPixel_d;
00198 
00202 typedef struct Gan_RGBAPixel_uc
00203 {
00204    unsigned char R, 
00205                  G, 
00206                  B, 
00207                  A; 
00208 } Gan_RGBAPixel_uc;
00209 
00213 typedef struct Gan_RGBAPixel_s
00214 {
00215    short R, 
00216          G, 
00217          B, 
00218          A; 
00219 } Gan_RGBAPixel_s;
00220 
00224 typedef struct Gan_RGBAPixel_us
00225 {
00226    unsigned short R, 
00227                   G, 
00228                   B, 
00229                   A; 
00230 } Gan_RGBAPixel_us;
00231 
00235 typedef struct Gan_RGBAPixel_i
00236 {
00237    int R, 
00238        G, 
00239        B, 
00240        A; 
00241 } Gan_RGBAPixel_i;
00242 
00246 typedef struct Gan_RGBAPixel_ui
00247 {
00248    unsigned int R, 
00249                 G, 
00250                 B, 
00251                 A; 
00252 } Gan_RGBAPixel_ui;
00253 
00257 typedef struct Gan_RGBAPixel_f
00258 {
00259    float R, 
00260          G, 
00261          B, 
00262          A; 
00263 } Gan_RGBAPixel_f;
00264 
00268 typedef struct Gan_RGBAPixel_d
00269 {
00270    double R, 
00271           G, 
00272           B, 
00273           A; 
00274 } Gan_RGBAPixel_d;
00275 
00276 #if (SIZEOF_CHAR == 1)
00277 
00280 typedef struct Gan_GLAPixel_uc Gan_GLAPixel_ui8;
00281 
00285 typedef struct Gan_RGBPixel_uc Gan_RGBPixel_ui8;
00286 
00291 typedef struct Gan_RGBAPixel_uc Gan_RGBAPixel_ui8;
00292 #else
00293 #error "8-bit type conflict"
00294 #endif /* #if (SIZEOF_CHAR == 1) */
00295 
00296 #if (SIZEOF_SHORT == 2)
00297 
00301 typedef struct Gan_GLAPixel_us Gan_GLAPixel_ui16;
00302 
00306 typedef struct Gan_RGBPixel_us Gan_RGBPixel_ui16;
00307 
00312 typedef struct Gan_RGBAPixel_us Gan_RGBAPixel_ui16;
00313 #else
00314 #error "16-bit type conflict"
00315 #endif /* #if (SIZEOF_SHORT == 2) */
00316 
00317 #if (SIZEOF_INT == 4)
00318 
00322 typedef struct Gan_GLAPixel_ui Gan_GLAPixel_ui32;
00323 
00327 typedef struct Gan_RGBPixel_ui Gan_RGBPixel_ui32;
00328 
00333 typedef struct Gan_RGBAPixel_ui Gan_RGBAPixel_ui32;
00334 #else
00335 #error "32-bit type conflict"
00336 #endif /* #if (SIZEOF_INT == 4) */
00337 
00341 typedef struct Gan_Pixel
00342 {
00344    Gan_ImageFormat format;
00345 
00347    Gan_Type type;
00348 
00350    union
00351    {
00353       union
00354       {
00355          unsigned char  uc;
00356          short          s;
00357          unsigned short us;
00358          int            i;
00359          unsigned int   ui;
00360          double         d;
00361          float          f;
00362          Gan_Bool       b;
00363          void          *p;
00364 
00365          gan_ui8 ui8;
00366          gan_ui16 ui16;
00367          gan_ui32 ui32;
00368       } gl;
00369 
00371       union
00372       {
00373          Gan_GLAPixel_uc uc;
00374          Gan_GLAPixel_s  s;
00375          Gan_GLAPixel_us us;
00376          Gan_GLAPixel_i  i;
00377          Gan_GLAPixel_ui ui;
00378          Gan_GLAPixel_d  d;
00379          Gan_GLAPixel_f  f;
00380 
00381          Gan_GLAPixel_ui8 ui8;
00382          Gan_GLAPixel_ui16 ui16;
00383          Gan_GLAPixel_ui32 ui32;
00384       } gla;
00385 
00387       union
00388       {
00389          Gan_RGBPixel_uc uc;
00390          Gan_RGBPixel_s  s;
00391          Gan_RGBPixel_us us;
00392          Gan_RGBPixel_i  i;
00393          Gan_RGBPixel_ui ui;
00394          Gan_RGBPixel_d  d;
00395          Gan_RGBPixel_f  f;
00396 
00397          Gan_RGBPixel_ui8 ui8;
00398          Gan_RGBPixel_ui16 ui16;
00399          Gan_RGBPixel_ui32 ui32;
00400       } rgb;
00401 
00403       union
00404       {
00405          Gan_RGBAPixel_uc uc;
00406          Gan_RGBAPixel_s  s;
00407          Gan_RGBAPixel_us us;
00408          Gan_RGBAPixel_i  i;
00409          Gan_RGBAPixel_ui ui;
00410          Gan_RGBAPixel_d  d;
00411          Gan_RGBAPixel_f  f;
00412 
00413          Gan_RGBAPixel_ui8 ui8;
00414          Gan_RGBAPixel_ui16 ui16;
00415          Gan_RGBAPixel_ui32 ui32;
00416       } rgba;
00417 
00419       union
00420       {
00421          Gan_Vector2_f f;
00422          Gan_Vector2   d;
00423          Gan_Vector2_s s;
00424          Gan_Vector2_i i;
00425       } vfield2D;
00426 
00428       union
00429       {
00430          Gan_Vector3_f f;
00431          Gan_Vector3   d;
00432          Gan_Vector3_s s;
00433          Gan_Vector3_i i;
00434       } vfield3D;
00435    } data;
00436 } Gan_Pixel;
00437 
00438 unsigned char  gan_pixel_rgbuc_to_yuc ( Gan_RGBPixel_uc *rgb );
00439 unsigned short gan_pixel_rgbuc_to_yus ( Gan_RGBPixel_uc *rgb );
00440 unsigned int   gan_pixel_rgbuc_to_yui ( Gan_RGBPixel_uc *rgb );
00441 unsigned char  gan_pixel_rgbus_to_yuc ( Gan_RGBPixel_us *rgb );
00442 unsigned short gan_pixel_rgbus_to_yus ( Gan_RGBPixel_us *rgb );
00443 float          gan_pixel_rgbui_to_yf  ( Gan_RGBPixel_ui *rgb );
00444 float          gan_pixel_rgbf_to_yf   ( Gan_RGBPixel_f  *rgb );
00445 double         gan_pixel_rgbd_to_yd   ( Gan_RGBPixel_d  *rgb );
00446 unsigned char  gan_pixel_rgbauc_to_yuc ( Gan_RGBAPixel_uc *rgba );
00447 unsigned short gan_pixel_rgbauc_to_yus ( Gan_RGBAPixel_uc *rgba );
00448 unsigned int   gan_pixel_rgbauc_to_yui ( Gan_RGBAPixel_uc *rgba );
00449 unsigned char  gan_pixel_rgbaus_to_yuc ( Gan_RGBAPixel_us *rgba );
00450 unsigned short gan_pixel_rgbaus_to_yus ( Gan_RGBAPixel_us *rgba );
00451 float          gan_pixel_rgbaui_to_yf  ( Gan_RGBAPixel_ui *rgba );
00452 float          gan_pixel_rgbaf_to_yf   ( Gan_RGBAPixel_f  *rgba );
00453 double         gan_pixel_rgbad_to_yd   ( Gan_RGBAPixel_d  *rgba );
00454 
00455 Gan_Bool gan_image_convert_pixel ( Gan_Pixel *inpix,
00456                                    Gan_ImageFormat format, Gan_Type type,
00457                                    Gan_Pixel *outpix, int *error_code );
00458 double gan_image_convert_scale ( Gan_Type gtFromType, Gan_Type gtToType );
00459 Gan_Bool gan_image_scale_pixel_q ( Gan_Pixel *pixel, double scale,
00460                                    Gan_Pixel *scaled_pixel );
00461 Gan_Bool gan_image_divide_pixel_q ( Gan_Pixel *pixel, double scale,
00462                                     Gan_Pixel *scaled_pixel );
00463 Gan_Bool gan_image_fill_zero_pixel ( Gan_Pixel *pixel );
00464 
00468 unsigned char gan_pixel_us_to_uc ( unsigned short x );
00469 
00473 unsigned char gan_pixel_ui_to_uc ( unsigned x );
00474 
00480 unsigned char gan_pixel_f_to_uc ( float x );
00481 
00487 unsigned char gan_pixel_d_to_uc ( double x );
00488 
00492 unsigned short gan_pixel_uc_to_us ( unsigned char x );
00493 
00497 unsigned short gan_pixel_ui_to_us ( unsigned x );
00498 
00502 short gan_pixel_i_to_s ( int x );
00503 
00509 unsigned short gan_pixel_f_to_us ( float x );
00510 
00516 unsigned short gan_pixel_d_to_us ( double x );
00517 
00521 unsigned int gan_pixel_uc_to_ui ( unsigned char x );
00522 
00526 unsigned int gan_pixel_us_to_ui ( unsigned short x );
00527 
00531 int gan_pixel_s_to_i ( short x );
00532 
00538 unsigned int gan_pixel_f_to_ui ( float x );
00539 
00545 unsigned int gan_pixel_d_to_ui ( double x );
00546 
00550 float gan_pixel_uc_to_f ( unsigned char x );
00551 
00555 float gan_pixel_us_to_f ( unsigned short x );
00556 
00560 float gan_pixel_ui_to_f ( unsigned int x );
00561 
00565 double gan_pixel_uc_to_d ( unsigned char x );
00566 
00570 double gan_pixel_us_to_d ( unsigned short x );
00571 
00575 double gan_pixel_ui_to_d ( unsigned int x );
00576    
00582 int gan_pixel_f_to_i ( float x );
00583 
00589 int gan_pixel_d_to_i ( double x );
00590 
00596 short gan_pixel_f_to_s ( float x );
00597 
00603 short gan_pixel_d_to_s ( double x );
00604 
00608 float gan_pixel_s_to_f ( short x );
00609 
00613 double gan_pixel_s_to_d ( short x );
00614    
00618 float gan_pixel_i_to_f ( int x );
00619 
00623 double gan_pixel_i_to_d ( int x );
00624    
00632 Gan_Bool gan_image_convert_pixel_q ( Gan_Pixel *inpix,
00633                                      Gan_ImageFormat format, Gan_Type type,
00634                                      Gan_Pixel *outpix );
00635 
00643 Gan_Bool gan_image_convert_pixel_i ( Gan_Pixel *pix,
00644                                      Gan_ImageFormat format, Gan_Type type );
00645 
00653 Gan_Bool gan_image_scale_pixel_i ( Gan_Pixel *pixel, double scale );
00654 
00662 Gan_Bool gan_image_divide_pixel_i ( Gan_Pixel *pixel, double scale );
00663 
00672 #ifdef __cplusplus
00673 }
00674 #endif
00675 
00676 #endif /* #ifndef _GAN_PIXEL_H */

Generated on Fri Mar 14 19:32:23 2003 by doxygen1.3-rc1