00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef header_canvas
00022 #define header_canvas
00023
00024 #include "generic_surfaceprovider.h"
00025 #include "../../Core/System/cl_assert.h"
00026
00027 class CL_Canvas : public CL_SurfaceProvider
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 {
00050 public:
00051 static CL_Surface *create(
00052 int width,
00053 int height,
00054 int no_sprs = 1,
00055 int red_mask = 0xff000000,
00056 int green_mask = 0x00ff0000,
00057 int blue_mask = 0x0000ff00,
00058 int alpha_mask = 0x000000ff,
00059 bool use_transcol = false,
00060 unsigned int transcol = 0)
00061 {
00062 return CL_Surface::create(
00063 new CL_Canvas(
00064 width,
00065 height,
00066 no_sprs,
00067 red_mask,
00068 green_mask,
00069 blue_mask,
00070 alpha_mask,
00071 use_transcol,
00072 transcol),
00073 true);
00074 }
00075
00085
00086
00087 CL_Canvas(
00088 int width,
00089 int height,
00090 int no_sprs = 1,
00091 int red_mask = 0xff000000,
00092 int green_mask = 0x00ff0000,
00093 int blue_mask = 0x0000ff00,
00094 int alpha_mask = 0x000000ff,
00095 bool use_transcol = false,
00096 unsigned int transcol = 0)
00097 {
00098 this->width = width;
00099 this->height = height;
00100 this->no_sprs = no_sprs;
00101 this->transcol = transcol;
00102 this->red_mask = red_mask;
00103 this->green_mask = green_mask;
00104 this->blue_mask = blue_mask;
00105 this->alpha_mask = alpha_mask;
00106 this->use_transcol = use_transcol;
00107
00108 bpp = get_depth();
00109
00110 data = new unsigned char[width * height * no_sprs * get_bytes_per_pixel()];
00111
00112 }
00113
00123
00124
00125
00126 virtual ~CL_Canvas()
00127 {
00128 delete[] data;
00129
00130 }
00131
00132
00133
00134 virtual unsigned int get_width() const { return width; }
00135
00136
00137 virtual unsigned int get_height() const { return height; }
00138
00139
00140 virtual unsigned int get_num_frames() const { return no_sprs; }
00141
00142
00143 virtual unsigned int get_red_mask() const { return red_mask; }
00144
00145
00146 virtual unsigned int get_green_mask() const { return green_mask; }
00147
00148
00149 virtual unsigned int get_blue_mask() const { return blue_mask; }
00150
00151
00152 virtual unsigned int get_alpha_mask() const { return alpha_mask; }
00153
00154
00155 virtual unsigned int get_pitch() const { return ((bpp+7)/8)*get_width(); }
00156
00157
00158 virtual bool is_indexed() const { return false; }
00159
00160
00161
00162
00163 virtual void set_palette(CL_Palette* palette) { ; }
00164
00165
00166 virtual CL_Palette *get_palette() const { return NULL; }
00167
00168
00169
00170 virtual void set_src_colorkey(unsigned int transcol) { this->transcol = transcol; }
00171
00172
00173 virtual bool uses_src_colorkey() const { return use_transcol; }
00174 virtual unsigned int get_src_colorkey() const { return transcol; }
00175
00176
00177 virtual void *get_data() const { cl_assert(data!=NULL); return data; }
00178
00179
00180
00181
00182 virtual void lock() { }
00183
00184
00185
00186 virtual void unlock() { }
00187
00188
00189
00190
00191 private:
00192
00193 int width, height, no_sprs, transcol;
00194 int red_mask, green_mask, blue_mask, alpha_mask;
00195 EPixelFormat pixelformat;
00196 unsigned char *data;
00197 int bpp;
00198 bool use_transcol;
00199 };
00200
00201 #endif