image.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Kenneth Gangstoe
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 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6