World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
ImageLoader.h
См. документацию.
1 #pragma once
2 #include "Engine/LOD.h"
3 #include "Engine/IocContainer.h"
4 #include "Engine/Strings.h"
5 
7 
9 
10 class ImageLoader {
11  public:
12  inline ImageLoader() {
13  this->log = EngineIoc::ResolveLogger();
14  }
15  virtual String GetResourceName() const { return this->resource_name; }
16 
17  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
18  IMAGE_FORMAT *format) = 0;
19 
20  protected:
22  Log *log;
23 };
24 
26  public:
28  const String &filename, uint16_t colorkey) {
29  this->resource_name = filename;
30  this->colorkey = colorkey;
31  this->lod = lod;
32  }
33 
34  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
36 
37  protected:
40 };
41 
43  public:
45  const String &filename) {
46  this->resource_name = filename;
47  this->lod = lod;
48  }
49 
50  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
52 
53  protected:
55 };
56 
57 class Alpha_LOD_Loader : public ImageLoader {
58  public:
59  inline Alpha_LOD_Loader(LODFile_IconsBitmaps *lod, const String &filename) {
60  this->resource_name = filename;
61  this->lod = lod;
62  }
63 
64  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
66 
67  protected:
69 };
70 
71 class PCX_Loader : public ImageLoader {
72  protected:
73  bool DecodePCX(const void *pcx_data, uint16_t *pOutPixels,
74  unsigned int *width, unsigned int *height);
75 };
76 
77 class PCX_File_Loader : public PCX_Loader {
78  public:
79  inline PCX_File_Loader(LODFile_IconsBitmaps *lod, const String &filename) {
80  this->resource_name = filename;
81  this->lod = lod;
82  }
83 
84  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
86 
87  protected:
88  bool InternalLoad(void *file, size_t size, unsigned int *width,
89  unsigned int *height, void **pixels,
92 };
93 
95  public:
96  inline PCX_LOD_File_Loader(LOD::File *lod, const String &filename)
97  : PCX_File_Loader(nullptr, filename) {
98  this->lod = lod;
99  }
100 
101  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
103 
104  protected:
106 };
107 
108 class PCX_LOD_Loader : public PCX_Loader {
109  public:
110  inline PCX_LOD_Loader(LOD::File *lod, const String &filename) {
111  this->resource_name = filename;
112  this->lod = lod;
113  }
114 
115  virtual bool Load(unsigned int *width, unsigned int *height,
116  void **out_pixels, IMAGE_FORMAT *format);
117 
118  protected:
120 };
121 
123  public:
125  const String &filename) {
126  this->resource_name = filename;
127  this->lod = lod;
128  }
129 
130  virtual bool Load(unsigned int *width, unsigned int *height,
131  void **out_pixels, IMAGE_FORMAT *format);
132 
133  protected:
135 };
136 
138  public:
140  const String &filename,
141  /*refactor*/ unsigned int lod_sprite_id) {
142  this->resource_name = filename;
143  this->lod = lod;
144  this->palette_id = palette_id;
145  this->lod_sprite_id = lod_sprite_id;
146  }
147 
148  virtual bool Load(unsigned int *width, unsigned int *height, void **pixels,
150 
151  protected:
153  unsigned int palette_id;
154  /*refactor*/ unsigned int lod_sprite_id;
155 };
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
Engine_::IocContainer
Definition: IocContainer.h:15
IocContainer.h
Alpha_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:144
LOD.h
Sprites_LOD_Loader
Definition: ImageLoader.h:137
PCX_LOD_File_Loader::PCX_LOD_File_Loader
PCX_LOD_File_Loader(LOD::File *lod, const String &filename)
Definition: ImageLoader.h:96
Sprites_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:333
Engine_::IocContainer::ResolveLogger
static Log * ResolveLogger()
Definition: IocContainer.cpp:51
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: SDL_egl.h:1596
PCX_LOD_File_Loader::lod
LOD::File * lod
Definition: ImageLoader.h:105
Alpha_LOD_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:68
ColorKey_LOD_Loader::ColorKey_LOD_Loader
ColorKey_LOD_Loader(LODFile_IconsBitmaps *lod, const String &filename, uint16_t colorkey)
Definition: ImageLoader.h:27
Alpha_LOD_Loader
Definition: ImageLoader.h:57
Alpha_LOD_Loader::Alpha_LOD_Loader
Alpha_LOD_Loader(LODFile_IconsBitmaps *lod, const String &filename)
Definition: ImageLoader.h:59
Image16bit_LOD_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:54
PCX_Loader
Definition: ImageLoader.h:71
Log
Definition: Log.h:3
PCX_LOD_Loader
Definition: ImageLoader.h:108
PCX_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **out_pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:253
PCX_Loader::DecodePCX
bool DecodePCX(const void *pcx_data, uint16_t *pOutPixels, unsigned int *width, unsigned int *height)
Definition: ImageLoader.cpp:179
Image.h
Image16bit_LOD_Loader::Image16bit_LOD_Loader
Image16bit_LOD_Loader(LODFile_IconsBitmaps *lod, const String &filename)
Definition: ImageLoader.h:44
format
SDL_AudioFormat format
Definition: SDL_audio.h:194
Sprites_LOD_Loader::lod_sprite_id
unsigned int lod_sprite_id
Definition: ImageLoader.h:154
Bitmaps_LOD_Loader
Definition: ImageLoader.h:122
ColorKey_LOD_Loader::colorkey
uint16_t colorkey
Definition: ImageLoader.h:38
PCX_File_Loader::PCX_File_Loader
PCX_File_Loader(LODFile_IconsBitmaps *lod, const String &filename)
Definition: ImageLoader.h:79
ImageLoader::ImageLoader
ImageLoader()
Definition: ImageLoader.h:12
Sprites_LOD_Loader::Sprites_LOD_Loader
Sprites_LOD_Loader(LODFile_Sprites *lod, unsigned int palette_id, const String &filename, unsigned int lod_sprite_id)
Definition: ImageLoader.h:139
Image16bit_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:108
PCX_LOD_File_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:232
width
EGLSurface EGLint EGLint EGLint width
Definition: SDL_egl.h:1596
PCX_File_Loader
Definition: ImageLoader.h:77
Bitmaps_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **out_pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:291
PCX_LOD_File_Loader
Definition: ImageLoader.h:94
ImageLoader::GetResourceName
virtual String GetResourceName() const
Definition: ImageLoader.h:15
Bitmaps_LOD_Loader::Bitmaps_LOD_Loader
Bitmaps_LOD_Loader(LODFile_IconsBitmaps *lod, const String &filename)
Definition: ImageLoader.h:124
ImageLoader
Definition: ImageLoader.h:10
ImageLoader::log
Log * log
Definition: ImageLoader.h:22
LODFile_Sprites
Definition: LOD.h:210
ImageLoader::resource_name
String resource_name
Definition: ImageLoader.h:21
Sprites_LOD_Loader::palette_id
unsigned int palette_id
Definition: ImageLoader.h:153
IMAGE_FORMAT
IMAGE_FORMAT
Definition: Image.h:4
ColorKey_LOD_Loader
Definition: ImageLoader.h:25
LODFile_IconsBitmaps
Definition: LOD.h:125
PCX_LOD_Loader::lod
LOD::File * lod
Definition: ImageLoader.h:119
PCX_File_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:91
PCX_File_Loader::InternalLoad
bool InternalLoad(void *file, size_t size, unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:208
ImageLoader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)=0
LOD::File
Definition: LOD.h:58
ColorKey_LOD_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:39
PCX_File_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:184
ColorKey_LOD_Loader::Load
virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format)
Definition: ImageLoader.cpp:72
PCX_LOD_Loader::PCX_LOD_Loader
PCX_LOD_Loader(LOD::File *lod, const String &filename)
Definition: ImageLoader.h:110
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:540
Bitmaps_LOD_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:134
Image16bit_LOD_Loader
Definition: ImageLoader.h:42
Sprites_LOD_Loader::lod
LODFile_Sprites * lod
Definition: ImageLoader.h:152
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
String
std::string String
Definition: Strings.h:10
lod
GLint lod
Definition: SDL_opengl_glext.h:3478
Strings.h