Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RageSurface.h

Go to the documentation of this file.
00001 /* RageSurface - holds a simple 2d graphic surface */ 00002 00003 #ifndef RAGE_SURFACE_H 00004 #define RAGE_SURFACE_H 00005 00006 /* XXX remove? */ 00007 struct RageSurfaceColor 00008 { 00009 uint8_t r, g, b, a; 00010 RageSurfaceColor() { } 00011 RageSurfaceColor( uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ ): 00012 r(r_), g(g_), b(b_), a(a_) { } 00013 00014 bool operator== ( const RageSurfaceColor &rhs ) const; 00015 }; 00016 00017 struct RageSurfacePalette 00018 { 00019 RageSurfaceColor colors[256]; 00020 int32_t ncolors; 00021 00022 /* Find the exact color; returns -1 if not found. */ 00023 int32_t FindColor( const RageSurfaceColor &color ) const; 00024 int32_t FindClosestColor( const RageSurfaceColor &color ) const; 00025 }; 00026 00027 struct RageSurfaceFormat 00028 { 00029 RageSurfaceFormat(); 00030 RageSurfaceFormat( const RageSurfaceFormat &cpy ); 00031 ~RageSurfaceFormat(); 00032 00033 int32_t BytesPerPixel; 00034 int32_t BitsPerPixel; 00035 uint32_t Mask[4]; 00036 uint32_t Shift[4]; 00037 uint8_t Loss[4]; 00038 uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */ 00039 uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */ 00040 RageSurfacePalette *palette; 00041 00042 void GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b ) const; 00043 00044 /* Return the decoded value for the given color; the result can be compared to 00045 * decodepixel() results. If the image is paletted and the color isn't found, 00046 * val is undefined and false is returned. */ 00047 bool MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val ) const; 00048 00049 /* MapRGBA, but also do a nearest-match on palette colors. */ 00050 uint32_t MapNearestRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const; 00051 00052 bool operator== ( const RageSurfaceFormat &rhs ) const; 00053 00054 /* Like operator==, but ignores the palette (which is really a part of the 00055 * surface, not the format). */ 00056 bool Equivalent( const RageSurfaceFormat &rhs ) const; 00057 }; 00058 00059 struct RageSurface 00060 { 00061 RageSurfaceFormat *format; /* compatibility only */ 00062 RageSurfaceFormat fmt; 00063 00064 uint8_t *pixels; 00065 bool pixels_owned; 00066 int32_t w, h, pitch; 00067 int32_t flags; 00068 00069 RageSurface(); 00070 RageSurface( const RageSurface &cpy ); 00071 ~RageSurface(); 00072 }; 00073 00074 RageSurface *CreateSurface( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask ); 00075 RageSurface *CreateSurfaceFrom( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask, uint8_t *pPixels, uint32_t pitch ); 00076 00077 #endif 00078 00079 /* 00080 * (c) 2001-2004 Glenn Maynard 00081 * All rights reserved. 00082 * 00083 * Permission is hereby granted, free of charge, to any person obtaining a 00084 * copy of this software and associated documentation files (the 00085 * "Software"), to deal in the Software without restriction, including 00086 * without limitation the rights to use, copy, modify, merge, publish, 00087 * distribute, and/or sell copies of the Software, and to permit persons to 00088 * whom the Software is furnished to do so, provided that the above 00089 * copyright notice(s) and this permission notice appear in all copies of 00090 * the Software and that both the above copyright notice(s) and this 00091 * permission notice appear in supporting documentation. 00092 * 00093 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00094 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00095 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00096 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00097 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00098 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00099 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00100 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00101 * PERFORMANCE OF THIS SOFTWARE. 00102 */

Generated on Thu Jan 27 20:57:29 2005 for StepMania by doxygen 1.3.7