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 "../../Core/System/sharedptr.h"
00036 #include "../../Core/Resources/resource_data_session.h"
00037 #include "../../Core/Math/origin.h"
00038 #include "color.h"
00039
00040 class CL_GraphicContext;
00041 class CL_VirtualDirectory;
00042 class CL_ResourceManager;
00043 class CL_Rect;
00044 class CL_Size;
00045 class CL_Rectf;
00046 class CL_Image_Impl;
00047 class CL_Texture;
00048 class CL_Subtexture;
00049 class CL_PixelBuffer;
00050
00054 class CL_API_DISPLAY CL_Image
00055 {
00058 public:
00060 CL_Image();
00061
00067 CL_Image(CL_GraphicContext &context, CL_Texture texture, CL_Rect rect);
00068
00073 CL_Image(CL_GraphicContext &context, CL_Subtexture &sub_texture);
00074
00079 CL_Image(CL_GraphicContext &gc, const CL_PixelBuffer &pixelbuffer);
00080
00085 CL_Image(CL_GraphicContext &context, const CL_StringRef &filename);
00086
00092 CL_Image(CL_GraphicContext &context, const CL_StringRef &filename, CL_VirtualDirectory &dir);
00093
00099 CL_Image(CL_GraphicContext &context, const CL_StringRef &resource_id, CL_ResourceManager *resources);
00100
00101 virtual ~CL_Image();
00103
00106 public:
00108 bool is_null() const;
00109
00111
00112 float get_scale_x() const;
00113
00115
00116 float get_scale_y() const;
00117
00119
00120 float get_alpha() const;
00121
00123
00124 CL_Colorf get_color() const;
00125
00127 void get_alignment(CL_Origin &origin, int &x, int &y) const;
00128
00132 CL_Size get_size() const;
00133
00135 int get_width() const;
00136
00138 int get_height() const;
00140
00143 public:
00145 bool operator==(const CL_Image &other) const
00146 {
00147 return impl==other.impl;
00148 }
00149
00151 bool operator!=(const CL_Image &other) const
00152 {
00153 return impl!=other.impl;
00154 }
00155
00157 bool operator<(const CL_Image &other) const
00158 {
00159 return impl < other.impl;
00160 }
00162
00165 public:
00172 void draw(
00173 CL_GraphicContext &gc,
00174 float x,
00175 float y) const;
00176
00177 void draw(
00178 CL_GraphicContext &gc,
00179 int x,
00180 int y) const;
00181
00182 void draw(
00183 CL_GraphicContext &gc,
00184 const CL_Rectf &src,
00185 const CL_Rectf &dest) const;
00186
00187 void draw(
00188 CL_GraphicContext &gc,
00189 const CL_Rectf &dest) const;
00190
00192
00193 void set_scale(float x, float y);
00194
00196
00197 void set_alpha(float alpha);
00198
00200
00201 void set_color(const CL_Colorf &color);
00202
00206 void set_color(const CL_Color& c) {CL_Colorf color; color.r = c.get_red() / 255.0f; color.g = c.get_green() / 255.0f; color.b = c.get_blue() / 255.0f; color.a = c.get_alpha() / 255.0f; set_color(color);}
00207
00209 void set_alignment(CL_Origin origin, int x = 0, int y = 0);
00211
00214 private:
00215 CL_SharedPtr<CL_Image_Impl> impl;
00217 };
00218