00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032 #pragma once
00033
00034 #include "../api_display.h"
00035 #include "pixel_format_type.h"
00036
00040 class CL_API_DISPLAY CL_PixelFormat
00041 {
00044
00045 public:
00055 CL_PixelFormat();
00056
00060 CL_PixelFormat(const CL_PixelFormat ©);
00061
00062 CL_PixelFormat(
00063 int depth,
00064 unsigned int red_mask,
00065 unsigned int green_mask,
00066 unsigned int blue_mask,
00067 unsigned int alpha_mask = 0,
00068 bool use_colorkey = false,
00069 unsigned int colorkey = 0,
00070 CL_PixelFormatType type = pixelformat_rgba);
00071
00075
00076 public:
00078 bool operator ==(const CL_PixelFormat &other) const;
00079
00081 bool operator !=(const CL_PixelFormat &other) const;
00082
00084 CL_PixelFormatType get_type() const { return type; }
00085
00087 bool has_colorkey() const { return colorkey_enabled; }
00088
00090 int get_depth() const { return depth; }
00091
00093 unsigned int get_colorkey() const { return colorkey; }
00094
00096 unsigned int get_red_mask() const { return red_mask; }
00097
00099 unsigned int get_green_mask() const { return green_mask; }
00100
00102 unsigned int get_blue_mask() const { return blue_mask; }
00103
00105 unsigned int get_alpha_mask() const { return alpha_mask; }
00106
00110
00111 public:
00113
00119 static CL_PixelFormat rgba8888;
00120
00122
00128 static CL_PixelFormat argb8888;
00129
00131
00136 static CL_PixelFormat rgb888;
00137
00139
00145 static CL_PixelFormat rgba4444;
00146
00148
00154 static CL_PixelFormat rgb555;
00155
00157
00163 static CL_PixelFormat rgb565;
00164
00166
00172 static CL_PixelFormat abgr8888;
00173
00175
00180 static CL_PixelFormat bgr888;
00181
00183
00189 static CL_PixelFormat abgr4444;
00190
00192
00198 static CL_PixelFormat bgr555;
00199
00201
00207 static CL_PixelFormat bgr565;
00208
00210 static int get_mask_shift(unsigned int mask);
00211
00213 static int get_mask_bits(unsigned int mask);
00214
00216 static unsigned int get_bitmask(int bits, int shift);
00217
00221
00222 public:
00224 void set_type(CL_PixelFormatType new_type) { type = new_type; }
00225
00227 void enable_colorkey(bool enable = true) { colorkey_enabled = enable; }
00228
00230 void set_colorkey(unsigned int i) { colorkey = i; }
00231
00233 void set_depth(int i) { depth = i; }
00234
00236 void set_red_mask(unsigned int i) { red_mask = i; }
00237
00239 void set_green_mask(unsigned int i) { green_mask = i; }
00240
00242 void set_blue_mask(unsigned int i) { blue_mask = i; }
00243
00245 void set_alpha_mask(unsigned int i) { alpha_mask = i; }
00246
00250
00251 private:
00253 CL_PixelFormatType type;
00254
00256 bool colorkey_enabled;
00257
00259 unsigned int colorkey;
00260
00262 unsigned int red_mask;
00263
00265 unsigned int green_mask;
00266
00268 unsigned int blue_mask;
00269
00271 unsigned int alpha_mask;
00272
00274 int depth;
00276 };
00277