Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

pixelformat.h

Go to the documentation of this file.
00001 #ifndef PIXELFORMAT_H
00002 #define PIXELFORMAT_H
00003 
00004 /****************************************************************************************/
00005 /*  PixelFormat.h                                                                       */
00006 /*                                                                                      */
00007 /*  Author: Charles Bloom                                                               */
00008 /*  Description:  The abstract Pixel primitives                                         */
00009 /*                                                                                      */
00010 /*  The contents of this file are subject to the Genesis3D Public License               */
00011 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00012 /*  compliance with the License. You may obtain a copy of the License at                */
00013 /*  http://www.genesis3d.com                                                            */
00014 /*                                                                                      */
00015 /*  Software distributed under the License is distributed on an "AS IS"                 */
00016 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00017 /*  the License for the specific language governing rights and limitations              */
00018 /*  under the License.                                                                  */
00019 /*                                                                                      */
00020 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00021 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00022 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00023 /*                                                                                      */
00024 /****************************************************************************************/
00025 
00026 #include "basetype.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 typedef enum            // all supported formats (including shifts)
00033 {
00034         GE_PIXELFORMAT_NO_DATA = 0,
00035         GE_PIXELFORMAT_8BIT,                            // PAL
00036         GE_PIXELFORMAT_8BIT_GRAY,               // no palette (intensity from bit value)
00037         GE_PIXELFORMAT_16BIT_555_RGB,
00038         GE_PIXELFORMAT_16BIT_555_BGR,
00039         GE_PIXELFORMAT_16BIT_565_RGB,   // #5
00040         GE_PIXELFORMAT_16BIT_565_BGR, 
00041         GE_PIXELFORMAT_16BIT_4444_ARGB, // #7
00042         GE_PIXELFORMAT_16BIT_1555_ARGB, 
00043         GE_PIXELFORMAT_24BIT_RGB,               // #9
00044         GE_PIXELFORMAT_24BIT_BGR,
00045         GE_PIXELFORMAT_24BIT_YUV,               // * see note below
00046         GE_PIXELFORMAT_32BIT_RGBX, 
00047         GE_PIXELFORMAT_32BIT_XRGB, 
00048         GE_PIXELFORMAT_32BIT_BGRX, 
00049         GE_PIXELFORMAT_32BIT_XBGR,
00050         GE_PIXELFORMAT_32BIT_RGBA, 
00051         GE_PIXELFORMAT_32BIT_ARGB,              // #17
00052         GE_PIXELFORMAT_32BIT_BGRA, 
00053         GE_PIXELFORMAT_32BIT_ABGR,
00054         
00055         GE_PIXELFORMAT_WAVELET,                 // #20 , Wavelet Compression
00056 
00057         GE_PIXELFORMAT_COUNT
00058 } gePixelFormat;
00059         
00060 /******
00061 
00062 there's something wacked out about these format names :
00063 
00064         for 16 bit & 32 bit , the _RGB or _BGR refers to their order
00065                 *in the word or dword* ; since we're on intel, this means
00066                 the bytes in the data file have the *opposite* order !!
00067                 (for example the 32 bit _ARGB is actually B,G,R,A in raw bytes)
00068         for 24 bit , the _RGB or _BGR refers to their order in the
00069                 actual bytes, so that windows bitmaps actually have
00070                 _RGB order in a dword !!
00071 
00072 * YUV : the pixelformat ops here are identical to those of 24bit_RGB ;
00073                 this is just a place-keeper to notify you that you should to a YUV_to_RGB conversion
00074 
00075 *********/
00076 
00077 #define GE_PIXELFORMAT_8BIT_PAL GE_PIXELFORMAT_8BIT
00078 
00079 typedef uint32  (*gePixelFormat_Composer   )(int R,int G,int B,int A);
00080 typedef void    (*gePixelFormat_Decomposer )(uint32 Pixel,int *R,int *G,int *B,int *A);
00081 
00082 typedef void    (*gePixelFormat_ColorGetter)(uint8 **ppData,int *R,int *G,int *B,int *A);
00083 typedef void    (*gePixelFormat_ColorPutter)(uint8 **ppData,int  R,int  G,int  B,int  A);
00084 
00085 typedef uint32  (*gePixelFormat_PixelGetter)(uint8 **ppData);
00086 typedef void    (*gePixelFormat_PixelPutter)(uint8 **ppData,uint32 Pixel);
00087 
00088 typedef struct gePixelFormat_Operations
00089 {
00090         uint32  RMask;
00091         uint32  GMask;
00092         uint32  BMask;
00093         uint32  AMask;
00094 
00095         int             RShift;
00096         int             GShift;
00097         int             BShift;
00098         int             AShift;
00099 
00100         int             RAdd;
00101         int             GAdd;
00102         int             BAdd;
00103         int             AAdd;
00104 
00105         int                     BytesPerPel;
00106         geBoolean       HasPalette;
00107         char *          Description;
00108         
00109         gePixelFormat_Composer          ComposePixel;
00110         gePixelFormat_Decomposer        DecomposePixel;
00111 
00112         gePixelFormat_ColorGetter       GetColor;
00113         gePixelFormat_ColorPutter       PutColor;
00114 
00115         gePixelFormat_PixelGetter       GetPixel;
00116         gePixelFormat_PixelPutter       PutPixel;
00117 } gePixelFormat_Operations;
00118 
00119         // the Masks double as boolean "HaveAlpha" .. etc..
00120 
00121 GENESISAPI const gePixelFormat_Operations * GENESISCC gePixelFormat_GetOperations( gePixelFormat Format );
00122 
00123         // quick accessors to _GetOps
00124 GENESISAPI geBoolean    GENESISCC gePixelFormat_IsValid(                gePixelFormat Format);
00125 GENESISAPI unsigned int GENESISCC gePixelFormat_BytesPerPel(    gePixelFormat Format );
00126 GENESISAPI geBoolean    GENESISCC gePixelFormat_HasPalette(             gePixelFormat Format );
00127 GENESISAPI geBoolean    GENESISCC gePixelFormat_HasAlpha(               gePixelFormat Format );
00128 GENESISAPI geBoolean    GENESISCC gePixelFormat_HasGoodAlpha(   gePixelFormat Format ); // more than 1 bit of alpha
00129 GENESISAPI const char * GENESISCC gePixelFormat_Description(    gePixelFormat Format );
00130 GENESISAPI geBoolean    GENESISCC gePixelFormat_IsRaw(                  gePixelFormat Format );
00131                                                                         // 'Raw' means pixels can be made with the Compose operations
00132 
00133 GENESISAPI uint32               GENESISCC gePixelFormat_ComposePixel(   gePixelFormat Format,int R,int G,int B,int A);
00134 GENESISAPI void                 GENESISCC gePixelFormat_DecomposePixel( gePixelFormat Format,uint32 Pixel,int *R,int *G,int *B,int *A);
00135                         
00136                                                                                                                         // these four functions move ppData to the next pixel
00137 
00138 GENESISAPI void                 GENESISCC gePixelFormat_GetColor(gePixelFormat Format,uint8 **ppData,int *R,int *G,int *B,int *A);
00139 GENESISAPI void                 GENESISCC gePixelFormat_PutColor(gePixelFormat Format,uint8 **ppData,int R,int G,int B,int A);
00140 
00141 GENESISAPI uint32               GENESISCC gePixelFormat_GetPixel(gePixelFormat Format,uint8 **ppData);
00142 GENESISAPI void                 GENESISCC gePixelFormat_PutPixel(gePixelFormat Format,uint8 **ppData,uint32 Pixel);
00143         
00144 GENESISAPI uint32               GENESISCC gePixelFormat_ConvertPixel(gePixelFormat Format,uint32 Pixel,gePixelFormat ToFormat);
00145 
00146 
00147 #ifdef __cplusplus
00148 }
00149 #endif
00150 
00151 #endif
00152 

Generated on Tue Sep 30 12:36:10 2003 for GTestAndEngine by doxygen 1.3.2