00001
00002
00003
#ifndef RAGE_SURFACE_H
00004
#define RAGE_SURFACE_H
00005
00006
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
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;
00039 uint32_t &
Rshift, &
Gshift, &
Bshift, &
Ashift;
00040 RageSurfacePalette *
palette;
00041
00042
void GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b )
const;
00043
00044
00045
00046
00047
bool MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val )
const;
00048
00049
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
00055
00056
bool Equivalent(
const RageSurfaceFormat &rhs )
const;
00057 };
00058
00059 struct RageSurface
00060 {
00061 RageSurfaceFormat *
format;
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
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102