provider_factory.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 ** Magnus Norddahl
27 ** Mark Page
28 ** (if your name is missing here, please add it)
29 */
30 
31 
32 #pragma once
33 
34 #include "../api_display.h"
35 #include <map>
36 #include "../../Core/IOData/file_system.h"
37 
38 namespace clan
39 {
42 
43 class PixelBuffer;
44 class ImageProviderType;
45 
47 class CL_API_DISPLAY ImageProviderFactory
48 {
51 
52 public:
54  static std::map<std::string, ImageProviderType *> types;
55 
59 
60 public:
67  static PixelBuffer try_load(
68  const std::string &filename,
69  const std::string &type = std::string(),
70  const FileSystem &fs = FileSystem(),
71  std::string *out_failure_reason = 0,
72  bool srgb = false);
73 
76 
79  static PixelBuffer load(
80  const std::string &filename,
81  const FileSystem &fs,
82  const std::string &type = std::string(),
83  bool srgb = false);
84 
85  static PixelBuffer load(
86  const std::string &fullname,
87  const std::string &type = std::string(),
88  bool srgb = false);
89 
90  static PixelBuffer load(
91  IODevice &file,
92  const std::string &type,
93  bool srgb = false);
94 
96 
98  static void save(
99  PixelBuffer buffer,
100  const std::string &filename,
101  FileSystem &fs,
102  const std::string &type = std::string());
103 
104  static void save(
105  PixelBuffer buffer,
106  const std::string &fullname,
107  const std::string &type = std::string());
108 
109  static void save(
110  PixelBuffer buffer,
111  IODevice &file,
112  const std::string &type);
114 };
115 
116 }
117 
I/O Device interface.
Definition: iodevice.h:51
Pixel data container.
Definition: pixel_buffer.h:69
static std::map< std::string, ImageProviderType * > types
Map of the class factories for each provider type.
Definition: provider_factory.h:54
Virtual File System (VFS).
Definition: file_system.h:48
Image Provider factory.
Definition: provider_factory.h:47