Go to the documentation of this file.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 #include "../Image/image_import_description.h"
00040 #include "../Render/texture.h"
00041
00042 class CL_GraphicContext;
00043 class CL_VirtualDirectory;
00044 class CL_ResourceManager;
00045 class CL_Rect;
00046 class CL_Size;
00047 class CL_Rectf;
00048 class CL_Image_Impl;
00049 class CL_Texture;
00050 class CL_Subtexture;
00051 class CL_PixelBuffer;
00052
00056 class CL_API_DISPLAY CL_Image
00057 {
00060 public:
00062 CL_Image();
00063
00069 CL_Image(CL_GraphicContext &context, CL_Texture texture, CL_Rect rect);
00070
00075 CL_Image(CL_GraphicContext &context, CL_Subtexture &sub_texture);
00076
00082 CL_Image(CL_GraphicContext &gc, const CL_PixelBuffer &pixelbuffer, const CL_Rect &rect);
00083
00089 CL_Image(CL_GraphicContext &context, const CL_StringRef &filename, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00090
00097 CL_Image(CL_GraphicContext &context, const CL_StringRef &filename, CL_VirtualDirectory &dir, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00098
00105 CL_Image(CL_GraphicContext &context, const CL_StringRef &resource_id, CL_ResourceManager *resources, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00106
00107 virtual ~CL_Image();
00109
00112 public:
00114 bool is_null() const { return !impl; }
00115
00117 void throw_if_null() const;
00118
00120
00121 float get_scale_x() const;
00122
00124
00125 float get_scale_y() const;
00126
00128
00129 float get_alpha() const;
00130
00132
00133 CL_Colorf get_color() const;
00134
00136 void get_alignment(CL_Origin &origin, int &x, int &y) const;
00137
00141 CL_Size get_size() const;
00142
00144 int get_width() const;
00145
00147 int get_height() const;
00148
00152 public:
00154 bool operator==(const CL_Image &other) const
00155 {
00156 return impl==other.impl;
00157 }
00158
00160 bool operator!=(const CL_Image &other) const
00161 {
00162 return impl!=other.impl;
00163 }
00164
00166 bool operator<(const CL_Image &other) const
00167 {
00168 return impl < other.impl;
00169 }
00171
00174 public:
00179 void draw(
00180 CL_GraphicContext &gc,
00181 float x,
00182 float y) const;
00183
00188 void draw(
00189 CL_GraphicContext &gc,
00190 int x,
00191 int y) const;
00192
00198 void draw(
00199 CL_GraphicContext &gc,
00200 const CL_Rectf &src,
00201 const CL_Rectf &dest) const;
00202
00207 void draw(
00208 CL_GraphicContext &gc,
00209 const CL_Rectf &dest) const;
00210
00212
00213 void set_scale(float x, float y);
00214
00216
00217 void set_alpha(float alpha);
00218
00220
00221 void set_color(const CL_Colorf &color);
00222
00226 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);}
00227
00229 void set_alignment(CL_Origin origin, int x = 0, int y = 0);
00230
00231 void set_wrap_mode(
00232 CL_TextureWrapMode wrap_s,
00233 CL_TextureWrapMode wrap_t);
00234
00236 void set_linear_filter(bool linear_filter = true);
00237
00242 void set_subimage(
00243 int x,
00244 int y,
00245 const CL_PixelBuffer &image,
00246 const CL_Rect &src_rect,
00247 int level = 0);
00249
00252 private:
00253 CL_SharedPtr<CL_Image_Impl> impl;
00255 };
00256