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
00029
00032
00033 #pragma once
00034
00035 #include "../api_display.h"
00036 #include "../../Core/System/sharedptr.h"
00037 #include "pixel_format.h"
00038 #include "../../Core/Math/rect.h"
00039
00040 class CL_Size;
00041 class CL_Rect;
00042 class CL_PixelFormat;
00043 class CL_Palette;
00044 class CL_Color;
00045 class CL_Colorf;
00046 class CL_PixelBuffer;
00047 class CL_PixelBuffer_Impl;
00048 class CL_ResourceManager;
00049 class CL_VirtualDirectory;
00050 class CL_IODevice;
00051
00055 class CL_API_DISPLAY CL_PixelBufferRef
00056 {
00059
00060 public:
00069 CL_PixelBufferRef();
00070
00074 CL_PixelBufferRef(const CL_PixelBuffer &buffer);
00075
00083 CL_PixelBufferRef(int width, int height, int pitch, const CL_PixelFormat &format, const void *data);
00084
00093 CL_PixelBufferRef(int width, int height, int pitch, const CL_PixelFormat &format, const CL_Palette *palette, const void *data);
00094
00098
00099 public:
00101 const CL_PixelFormat &get_format() const { return format; }
00102
00104 const CL_Palette *get_palette() const { return palette; }
00105
00107 int get_width() const { return width; }
00108
00110 int get_height() const { return height; }
00111
00113 CL_Size get_size() const { return CL_Size(width, height); }
00114
00116 unsigned int get_pitch() const { return pitch; }
00117
00119 void *get_data() { return data; }
00120
00121 const void *get_data() const { return data; }
00122
00126
00127 public:
00128
00134 CL_PixelBufferRef get_subimage(const CL_Rect &rect) const;
00135
00137 CL_PixelBuffer copy() const;
00138
00147 void convert(CL_PixelBuffer target) const;
00148
00149 void convert(void *buffer, const CL_PixelFormat &format, int dest_pitch,
00150 const CL_Rect &dest_rect, const CL_Rect &src_rect = CL_Rect(0,0,0,0)) const;
00151
00157 void convert_line(void *buffer, const CL_PixelFormat &format, int y) const;
00158
00160 CL_PixelBuffer to_format(const CL_PixelFormat &format) const;
00161
00162 private:
00163 CL_PixelFormat format;
00164 CL_Palette *palette;
00165 int width;
00166 int height;
00167 unsigned int pitch;
00168 void *data;
00170 };
00171
00175 class CL_API_DISPLAY CL_PixelBuffer
00176 {
00179
00180 public:
00189 CL_PixelBuffer();
00190
00194 CL_PixelBuffer(const CL_PixelBufferRef &other);
00195
00203 CL_PixelBuffer(int width, int height, int pitch, const CL_PixelFormat &format, const void *data = 0);
00204
00213 CL_PixelBuffer(int width, int height, int pitch, const CL_PixelFormat &format, const CL_Palette &palette, const void *data = 0);
00214
00218 CL_PixelBuffer(const CL_PixelBuffer ©);
00219
00223 CL_PixelBuffer(const CL_StringRef &fullname);
00224
00229 CL_PixelBuffer(const CL_StringRef &filename, const CL_VirtualDirectory &dir);
00230
00235 CL_PixelBuffer(CL_IODevice &file, const CL_String &image_type);
00236
00237 virtual ~CL_PixelBuffer();
00238
00242
00243 public:
00245 bool is_null() const;
00246
00248 CL_PixelBuffer copy() const;
00249
00251 const CL_PixelFormat &get_format() const;
00252
00254 const CL_Palette *get_palette() const;
00255
00257 int get_width() const;
00258
00260 int get_height() const;
00261
00263 CL_Size get_size() const;
00264
00266 unsigned int get_pitch() const;
00267
00269 void *get_data();
00270
00271 const void *get_data() const;
00272
00274 CL_Color get_pixel(int x, int y);
00275
00277 CL_PixelBufferRef get_subimage(const CL_Rect &rect) const;
00278
00282
00283 public:
00285 CL_PixelBuffer &operator =(const CL_PixelBuffer ©);
00286
00288 operator bool () const;
00289
00298 void convert(CL_PixelBuffer target) const;
00299
00300 void convert(void *buffer, const CL_PixelFormat &format, int dest_pitch,
00301 const CL_Rect &dest_rect, const CL_Rect &src_rect = CL_Rect(0,0,0,0)) const;
00302
00308 void convert_line(void *buffer, const CL_PixelFormat &format, int y) const;
00309
00311 CL_PixelBuffer to_format(const CL_PixelFormat &format) const;
00312
00317 void set_colorkey(bool enabled, unsigned int colorkey);
00318
00320 void draw_pixel(int x, int y, const CL_Colorf &color);
00321
00323 void flip_vertical();
00324
00328
00329 private:
00330 CL_SharedPtr<CL_PixelBuffer_Impl> impl;
00332 };
00333