gml_Bitmap.h

Go to the documentation of this file.
00001 /**
00002  * @file gml_Bitmap.h
00003  *
00004  *  Defines the gml_TBitmap struct: a structure that describes how the set of pixels of a
00005  *  bitmap are organized in memory.
00006  *  Defines gml_TPixelEncoding that explains the way a pixel is represented in memory.
00007  *
00008  * Copyright (c) 1994-2004 CLIPS-IMAG
00009  *
00010  * See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00011  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00012  *
00013  *  May 20, 2003 (FB)
00014  *    Extreme simplification. Keep minimal stuff in gml_TBitmap.h, put other stuff in other files.
00015  *    Ensure possible compilation with C (not only C++): gml_TBitmap is a struct with no methods.
00016  *    Conversion to gml standards.
00017  *    Suppress BitmapSpec type. The bitmap specifications are now at the same level as the pixel
00018  *      buffer in the gml_TBitmap structure.
00019  *  
00020  *  August 10, 1998 (FB)
00021  *    split UBitmap.cc in UBitmap_base.cc, UBitmap_misc.cc, ...
00022  *
00023  *  Created on March 1994 (FB).
00024  */
00025 
00026 #ifndef __GML_BITMAP__
00027 #define __GML_BITMAP__
00028 
00029 #include "gml/base/gml_Types.h"
00030 
00031 /**
00032  * gml_TPixelEncoding --
00033  *
00034  *  Defines the way a pixel is represented in memory order, ie. this
00035  *  does not depend on the machine byte ordering in words
00036  *  (big or little endian).
00037  */
00038 
00039 /*  
00040  *  WARNING ! When defining new pixel encoding, make sure
00041  *  that encoding >> 8 is the number of bytes per pixel for
00042  *  the new encoding (see gml_PixelSize() below).
00043  */
00044 typedef enum
00045 {
00046   /** NULL encoding: invalid encoding, may mean "undefined" */
00047   gml_cEncoding_NULL=0,
00048 
00049   /* 1 byte per pixel encodings */
00050   gml_cEncoding_G_8=256,          /**< 8 bits greyscale, 0 is black, 255 is white */
00051 
00052   /* 2 bytes per pixel encoding */
00053   gml_cEncoding_G_16=512,         /**< 16 bit greyscale, 0 is black */
00054 
00055   /* 3 bytes per pixel encoding */
00056   gml_cEncoding_RGB_888=768,
00057   gml_cEncoding_HSV_888,          /**< HSV colorspace */
00058   gml_cEncoding_LRG_888,          /**< LRG colorspace */
00059   gml_cEncoding_HLS_888,          /**< HLS colorspace */
00060   gml_cEncoding_YUV_888,          /**< YUV colorspace */
00061 
00062   /* 4 bytes per pixel encoding */
00063   gml_cEncoding_XRGB_8888=1024,
00064   gml_cEncoding_ARGB_8888,
00065   gml_cEncoding_XYUV_8888,
00066   gml_cEncoding_G_F,             /**< single precision floating-point greyscale, 0 is black, 1 is white */
00067   gml_cEncoding_G_32,            /**< 32-bit greyscale, 0 is black */
00068 
00069   gml_cEncoding_RGB_FFF=1536,
00070   
00071   gml_cEncoding_HSV_SSS,
00072   gml_cEncoding_LRG_SSS,
00073   gml_cEncoding_HLS_SSS,
00074   gml_cEncoding_YUV_SSS,
00075   
00076   gml_cEncoding_LRG_FFF=3072,
00077   gml_cEncoding_HLS_FFF,
00078   gml_cEncoding_HSV_FFF,
00079   gml_cEncoding_YUV_FFF,
00080 
00081   /* 16 bytes per pixel encoding */
00082   gml_cEncoding_ARGB_FFFF=4096
00083 
00084 } gml_TPixelEncoding;
00085 
00086 
00087     
00088 /**
00089  *  gml_PixelSize --
00090  *
00091  *  Returns the size, in byte, of the memory storage of a pixel
00092  *  given a PixelEncoding. Compile-time constant.
00093  */
00094 
00095 inline static
00096 int gml_PixelSize (gml_TPixelEncoding encoding)
00097 {
00098   return (encoding >> 8);
00099 }
00100 
00101 /**
00102  * gml_TBitmap --
00103  *
00104  *  A structure that describes how the set of pixels of a
00105  *  bitmap are organized in memory.
00106  */  
00107 
00108 typedef struct gml_TBitmap
00109 {
00110   void*               fBuffer;        /**< pointer to the first byte of bitmap's memory */
00111   int                 fWidth;         /**< number of columns of pixels in bitmap */
00112   int                 fHeight;        /**< number of rows of pixels in bitmap */
00113   gml_TPixelEncoding  fEncoding;      /**< how pixels are encoded in memory */
00114   int                 fRowOffset;     /**< number of BYTES from one row to the next one (positive) */
00115   int                 fFromTop;       /**< non-zero if the first row in memory (lowest address)
00116                                            is the top row of the bitmap */
00117 } gml_TBitmap;
00118 
00119 
00120 #endif /* ifndef __GMLBITMAP__ */
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.