World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Класс Bitmaps_LOD_Loader

#include <ImageLoader.h>

+ Граф наследования:Bitmaps_LOD_Loader:
+ Граф связей класса Bitmaps_LOD_Loader:

Открытые члены

 Bitmaps_LOD_Loader (LODFile_IconsBitmaps *lod, const String &filename)
 
virtual bool Load (unsigned int *width, unsigned int *height, void **out_pixels, IMAGE_FORMAT *format)
 
- Открытые члены унаследованные от ImageLoader
 ImageLoader ()
 
virtual String GetResourceName () const
 

Защищенные данные

LODFile_IconsBitmapslod
 
- Защищенные данные унаследованные от ImageLoader
String resource_name
 
Loglog
 

Подробное описание

См. определение в файле ImageLoader.h строка 122

Конструктор(ы)

◆ Bitmaps_LOD_Loader()

Bitmaps_LOD_Loader::Bitmaps_LOD_Loader ( LODFile_IconsBitmaps lod,
const String filename 
)
inline

См. определение в файле ImageLoader.h строка 124

125  {
126  this->resource_name = filename;
127  this->lod = lod;
128  }

Перекрестные ссылки lod и ImageLoader::resource_name.

Методы

◆ Load()

bool Bitmaps_LOD_Loader::Load ( unsigned int *  width,
unsigned int *  height,
void **  out_pixels,
IMAGE_FORMAT format 
)
virtual

Замещает ImageLoader.

См. определение в файле ImageLoader.cpp строка 291

292  {
293  *width = 0;
294  *height = 0;
295  *out_pixels = nullptr;
297 
298  auto tex = lod->GetTexture(lod->LoadTexture(this->resource_name.c_str()));
299 
300  int num_pixels = tex->header.uTextureWidth * tex->header.uTextureHeight;
301  auto pixels = new uint16_t[num_pixels];
302  if (pixels) {
303  *width = tex->header.uTextureWidth;
304  *height = tex->header.uTextureHeight;
306 
307  if (tex->header.pBits & 2) { // hardware bitmap
308  HWLTexture *hwl = render->LoadHwlBitmap(this->resource_name.c_str());
309  if (hwl) {
310  // linear scaling
311  for (int s = 0; s < tex->header.uTextureHeight; ++s) {
312  for (int t = 0; t < tex->header.uTextureWidth; ++t) {
313  unsigned int resampled_x = t * hwl->uWidth / tex->header.uTextureWidth,
314  resampled_y = s * hwl->uHeight / tex->header.uTextureHeight;
315  unsigned short sample = hwl->pPixels[resampled_y * hwl->uWidth + resampled_x];
316 
317  pixels[s * tex->header.uTextureWidth + t] = sample;
318  }
319  }
320 
321  delete[] hwl->pPixels;
322  delete hwl;
323  }
324 
325  *out_pixels = pixels;
326  return true;
327  }
328  }
329 
330  return false;
331 }

Перекрестные ссылки IMAGE_FORMAT_A1R5G5B5, IMAGE_INVALID_FORMAT, HWLTexture::pPixels, render, ImageLoader::resource_name, HWLTexture::uHeight и HWLTexture::uWidth.

Данные класса

◆ lod

LODFile_IconsBitmaps* Bitmaps_LOD_Loader::lod
protected

См. определение в файле ImageLoader.h строка 134

Используется в Bitmaps_LOD_Loader().


Объявления и описания членов классов находятся в файлах:
uint16_t
unsigned __int16 uint16_t
Definition: SDL_config.h:37
s
GLdouble s
Definition: SDL_opengl.h:2063
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: SDL_egl.h:1596
IMAGE_INVALID_FORMAT
@ IMAGE_INVALID_FORMAT
Definition: Image.h:12
HWLTexture
Definition: HWLContainer.h:9
format
SDL_AudioFormat format
Definition: SDL_audio.h:194
width
EGLSurface EGLint EGLint EGLint width
Definition: SDL_egl.h:1596
HWLTexture::uHeight
unsigned int uHeight
Definition: HWLContainer.h:18
HWLTexture::uWidth
unsigned int uWidth
Definition: HWLContainer.h:17
ImageLoader::resource_name
String resource_name
Definition: ImageLoader.h:21
HWLTexture::pPixels
uint16_t * pPixels
Definition: HWLContainer.h:21
t
GLdouble GLdouble t
Definition: SDL_opengl.h:2071
IMAGE_FORMAT_A1R5G5B5
@ IMAGE_FORMAT_A1R5G5B5
Definition: Image.h:6
Bitmaps_LOD_Loader::lod
LODFile_IconsBitmaps * lod
Definition: ImageLoader.h:134
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
lod
GLint lod
Definition: SDL_opengl_glext.h:3478
render
std::shared_ptr< IRender > render
Definition: RenderOpenGL.cpp:52