ClanLib
2.3.7
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
Sources
API
Display
2D
image.h
Go to the documentation of this file.
1
/*
2
** ClanLib SDK
3
** Copyright (c) 1997-2011 The ClanLib Team
4
**
5
** This software is provided 'as-is', without any express or implied
6
** warranty. In no event will the authors be held liable for any damages
7
** arising from the use of this software.
8
**
9
** Permission is granted to anyone to use this software for any purpose,
10
** including commercial applications, and to alter it and redistribute it
11
** freely, subject to the following restrictions:
12
**
13
** 1. The origin of this software must not be misrepresented; you must not
14
** claim that you wrote the original software. If you use this software
15
** in a product, an acknowledgment in the product documentation would be
16
** appreciated but is not required.
17
** 2. Altered source versions must be plainly marked as such, and must not be
18
** misrepresented as being the original software.
19
** 3. This notice may not be removed or altered from any source distribution.
20
**
21
** Note: Some of the libraries ClanLib may link to may have additional
22
** requirements or restrictions.
23
**
24
** File Author(s):
25
**
26
** Kenneth Gangstoe
27
*/
28
31
32
#pragma once
33
34
#include "../api_display.h"
35
#include "../../Core/System/sharedptr.h"
36
#include "../../Core/Resources/resource_data_session.h"
37
#include "../../Core/Math/origin.h"
38
#include "
color.h
"
39
#include "../Image/image_import_description.h"
40
#include "../Render/texture.h"
41
42
class
CL_GraphicContext
;
43
class
CL_VirtualDirectory
;
44
class
CL_ResourceManager
;
45
class
CL_Rect
;
46
class
CL_Size
;
47
class
CL_Rectf
;
48
class
CL_Image_Impl;
49
class
CL_Texture
;
50
class
CL_Subtexture
;
51
class
CL_PixelBuffer
;
52
56
class
CL_API_DISPLAY
CL_Image
57
{
60
public
:
62
CL_Image
();
63
69
CL_Image
(
CL_GraphicContext
&context,
CL_Texture
texture,
CL_Rect
rect);
70
75
CL_Image
(
CL_GraphicContext
&context,
CL_Subtexture
&sub_texture);
76
82
CL_Image
(
CL_GraphicContext
&gc,
const
CL_PixelBuffer
&pixelbuffer,
const
CL_Rect
&rect);
83
89
CL_Image
(
CL_GraphicContext
&context,
const
CL_StringRef
&filename,
const
CL_ImageImportDescription
&import_desc =
CL_ImageImportDescription
());
90
97
CL_Image
(
CL_GraphicContext
&context,
const
CL_StringRef
&filename,
CL_VirtualDirectory
&dir,
const
CL_ImageImportDescription
&import_desc =
CL_ImageImportDescription
());
98
105
CL_Image
(
CL_GraphicContext
&context,
const
CL_StringRef
&resource_id,
CL_ResourceManager
*resources,
const
CL_ImageImportDescription
&import_desc =
CL_ImageImportDescription
());
106
107
virtual
~
CL_Image
();
109
112
public
:
114
bool
is_null
()
const
{
return
!impl; }
115
117
void
throw_if_null()
const
;
118
120
121
float
get_scale_x()
const
;
122
124
125
float
get_scale_y()
const
;
126
128
129
float
get_alpha()
const
;
130
132
133
CL_Colorf
get_color()
const
;
134
136
void
get_alignment(
CL_Origin
&origin,
int
&x,
int
&y)
const
;
137
141
CL_Size
get_size()
const
;
142
144
int
get_width()
const
;
145
147
int
get_height()
const
;
148
152
public
:
154
bool
operator==
(
const
CL_Image
&other)
const
155
{
156
return
impl==other.impl;
157
}
158
160
bool
operator!=
(
const
CL_Image
&other)
const
161
{
162
return
impl!=other.impl;
163
}
164
166
bool
operator<
(
const
CL_Image
&other)
const
167
{
168
return
impl < other.impl;
169
}
171
174
public
:
179
void
draw(
180
CL_GraphicContext
&gc,
181
float
x,
182
float
y)
const
;
183
188
void
draw(
189
CL_GraphicContext
&gc,
190
int
x,
191
int
y)
const
;
192
198
void
draw(
199
CL_GraphicContext
&gc,
200
const
CL_Rectf
&src,
201
const
CL_Rectf
&dest)
const
;
202
207
void
draw(
208
CL_GraphicContext
&gc,
209
const
CL_Rectf
&dest)
const
;
210
212
213
void
set_scale(
float
x,
float
y);
214
216
217
void
set_alpha(
float
alpha);
218
220
221
void
set_color(
const
CL_Colorf
&color);
222
226
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);}
227
229
void
set_alignment(
CL_Origin
origin,
int
x = 0,
int
y = 0);
230
231
void
set_wrap_mode(
232
CL_TextureWrapMode
wrap_s,
233
CL_TextureWrapMode
wrap_t);
234
236
void
set_linear_filter(
bool
linear_filter =
true
);
237
242
void
set_subimage(
243
int
x,
244
int
y,
245
const
CL_PixelBuffer
&image,
246
const
CL_Rect
&src_rect,
247
int
level = 0);
249
252
private
:
253
CL_SharedPtr<CL_Image_Impl> impl;
255
};
256
Generated on Fri Jun 14 2013 13:05:45 for ClanLib by
1.8.4