ClanLib  2.3.7
sprite_description.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/Text/string_types.h"
36 #include "../Render/graphic_context.h"
37 #include "../Render/texture.h"
38 #include "../Image/pixel_buffer.h"
39 #include <vector>
40 
41 class CL_SpriteDescription_Impl;
42 class CL_ResourceManager;
43 
48 {
49 public:
50  enum FrameType
51  {
54  };
55 
56 public:
57 
62  CL_SpriteDescriptionFrame(CL_PixelBuffer pixelbuffer, CL_Rect rect) : pixelbuffer(pixelbuffer), rect(rect), type(type_pixelbuffer), delay(1.0) { }
63 
68  CL_SpriteDescriptionFrame(CL_Texture texture, CL_Rect rect) : texture(texture), rect(rect), type(type_texture), delay(1.0) { }
69 
74  double delay;
75 };
76 
86 {
89 public:
95 
102 
107 
109 
113 public:
115  const std::vector<CL_SpriteDescriptionFrame> &get_frames() const;
116 
120 public:
122  CL_SpriteDescription &operator =(const CL_SpriteDescription &copy);
123 
129  void add_frame(const CL_PixelBuffer &pixelbuffer);
130 
134  void add_frame(const CL_Texture &texture);
135 
139  void add_frame(const CL_StringRef &fullname, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
140 
145  void add_frame(CL_IODevice &file, const CL_String &image_type, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
146 
151  void add_frame(const CL_StringRef &filename, CL_VirtualDirectory &dir, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
152 
158  void add_frames(const CL_Texture &texture, CL_Rect *frames, int num_frames);
159 
161 
169  void add_gridclipped_frames(
170  const CL_PixelBuffer &pixelbuffer,
171  int xpos, int ypos,
172  int width, int height,
173  int xarray = 1, int yarray = 1,
174  int array_skipframes = 0,
175  int xspacing = 0, int yspacing = 0);
176 
177  void add_gridclipped_frames(
178  const CL_Texture &texture,
179  int xpos, int ypos,
180  int width, int height,
181  int xarray = 1, int yarray = 1,
182  int array_skipframes = 0,
183  int xspacing = 0, int yspacing = 0);
184 
186 
195  void add_alphaclipped_frames(
196  const CL_PixelBuffer &pixelbuffer,
197  int xpos = 0, int ypos = 0,
198  double trans_limit = 0.05f);
199 
200  void add_alphaclipped_frames(
201  const CL_Texture &texture,
202  int xpos = 0, int ypos = 0,
203  double trans_limit = 0.05f);
204 
206 
214  void add_alphaclipped_frames_free(
215  const CL_PixelBuffer &pixelbuffer,
216  int xpos = 0, int ypos = 0,
217  double trans_limit = 0.05f);
218 
219  void add_alphaclipped_frames_free(
220  const CL_Texture &texture,
221  int xpos = 0, int ypos = 0,
222  double trans_limit = 0.05f);
223 
225  void set_frame_delay(int frame, double delay);
226 
230 private:
232  CL_SharedPtr<CL_SpriteDescription_Impl> impl;
234 };
235