xm_image.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 
00003 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
00004 All Rights Reserved.
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a
00007 copy of this software and associated documentation files (the
00008 "Software"), to deal in the Software without restriction, including
00009 without limitation the rights to use, copy, modify, merge, publish,
00010 distribute, sub license, and/or sell copies of the Software, and to
00011 permit persons to whom the Software is furnished to do so, subject to
00012 the following conditions:
00013 
00014 The above copyright notice and this permission notice (including the
00015 next paragraph) shall be included in all copies or substantial portions
00016 of the Software.
00017 
00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
00022 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025 
00026 **************************************************************************/
00027 
00028 /*
00029  * Authors:
00030  *   Kevin E. Martin <kevin@precisioninsight.com>
00031  *   Brian Paul <brian@precisioninsight.com>
00032  */
00033 
00034 #ifndef _XM_IMAGE_H_
00035 #define _XM_IMAGE_H_
00036 
00037 #define XMESA_USE_PUTPIXEL_MACRO
00038 
00039 extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
00040                                     char *data);
00041 extern void XMesaDestroyImage(XMesaImage *image);
00042 extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
00043 #ifdef XMESA_USE_PUTPIXEL_MACRO
00044 #define XMesaPutPixel(__i,__x,__y,__p) \
00045 { \
00046     CARD8  *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
00047     CARD8  *__i8; \
00048     CARD16 *__i16; \
00049     CARD32 *__i32; \
00050     switch (__i->bits_per_pixel) { \
00051     case 8: \
00052         __i8 = (CARD8 *)__row; \
00053         __i8[__x] = (CARD8)__p; \
00054         break; \
00055     case 15: \
00056     case 16: \
00057         __i16 = (CARD16 *)__row; \
00058         __i16[__x] = (CARD16)__p; \
00059         break; \
00060     case 24: /* WARNING: architecture specific code */ \
00061         __i8 = (CARD8 *)__row; \
00062         __i8[__x*3]   = (CARD8)(__p); \
00063         __i8[__x*3+1] = (CARD8)(__p>>8); \
00064         __i8[__x*3+2] = (CARD8)(__p>>16); \
00065         break; \
00066     case 32: \
00067         __i32 = (CARD32 *)__row; \
00068         __i32[__x] = (CARD32)__p; \
00069         break; \
00070     } \
00071 }
00072 #else
00073 extern void XMesaPutPixel(XMesaImage *image, int x, int y,
00074                           unsigned long pixel);
00075 #endif
00076 
00077 #endif /* _XM_IMAGE_H_ */

Generated on Tue Sep 29 06:25:18 2009 for Gallium3D by  doxygen 1.5.4