34 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
35 #include <SDL_image.h>
40 #ifndef SDL_BIG_ENDIAN
41 #error missing SDL_endian.h
52 SDL_Surface *
const tmpImage =
loadPng(rw);
53 if (tmpImage ==
nullptr)
55 logger->
log(
"Error, image load failed: %s", SDL_GetError());
68 SDL_Surface *
const tmpImage =
loadPng(rw);
69 if (tmpImage ==
nullptr)
71 logger->
log(
"Error, image load failed: %s", SDL_GetError());
77 rgba.palette =
nullptr;
78 rgba.BitsPerPixel = 32;
79 rgba.BytesPerPixel = 4;
81 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
82 rgba.Rmask = 0x000000FFU;
83 rgba.Gmask = 0x0000FF00U;
84 rgba.Bmask = 0x00FF0000U;
85 rgba.Amask = 0xFF000000U;
88 rgba.Rmask = 0xFF000000U;
89 rgba.Gmask = 0x00FF0000U;
90 rgba.Bmask = 0x0000FF00U;
91 rgba.Amask = 0x000000FFU;
95 tmpImage, &rgba, SDL_SWSURFACE);
101 uint32_t *
const pixels =
static_cast<uint32_t *
>(surf->pixels);
102 const int type = dye.
getType();
110 DYEPALETTEP(pal, SColor)(pixels, surf->w * surf->h);
117 DYEPALETTEP(pal, AColor)(pixels, surf->w * surf->h);
123 dye.
normalDye(pixels, surf->w * surf->h);
136 if (tmpImage ==
nullptr)
138 SDL_PixelFormat RGBAFormat;
139 RGBAFormat.palette =
nullptr;
141 RGBAFormat.colorkey = 0;
142 RGBAFormat.alpha = 0;
145 RGBAFormat.BitsPerPixel = 32;
146 RGBAFormat.BytesPerPixel = 4;
147 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
148 RGBAFormat.Rmask = 0xFF000000U;
149 RGBAFormat.Rshift = 0;
150 RGBAFormat.Rloss = 0;
151 RGBAFormat.Gmask = 0x00FF0000U;
152 RGBAFormat.Gshift = 8;
153 RGBAFormat.Gloss = 0;
154 RGBAFormat.Bmask = 0x0000FF00U;
155 RGBAFormat.Bshift = 16;
156 RGBAFormat.Bloss = 0;
157 RGBAFormat.Amask = 0x000000FFU;
158 RGBAFormat.Ashift = 24;
159 RGBAFormat.Aloss = 0;
162 RGBAFormat.Rmask = 0x000000FFU;
163 RGBAFormat.Rshift = 24;
164 RGBAFormat.Rloss = 0;
165 RGBAFormat.Gmask = 0x0000FF00U;
166 RGBAFormat.Gshift = 16;
167 RGBAFormat.Gloss = 0;
168 RGBAFormat.Bmask = 0x00FF0000U;
169 RGBAFormat.Bshift = 8;
170 RGBAFormat.Bloss = 0;
171 RGBAFormat.Amask = 0xFF000000U;
172 RGBAFormat.Ashift = 0;
173 RGBAFormat.Aloss = 0;
181 if (image ==
nullptr)
183 if (image->format !=
nullptr)
185 const SDL_PixelFormat *
const format = image->format;
186 logger->
log(
"Bytes per pixel: %d", format->BytesPerPixel);
188 logger->
log(
"Format: %u", format->format);
192 logger->
log(
"Color key: %u", format->colorkey);
195 logger->
log(
"Loss: %02x, %02x, %02x, %02x",
200 logger->
log(
"Shift: %02x, %02x, %02x, %02x",
205 logger->
log(
"Mask: %08x, %08x, %08x, %08x", format->Rmask,
206 format->Gmask, format->Bmask, format->Amask);
211 logger->
log(
"Offset: %d", image->offset);
220 if (IMG_isPNG(rw) != 0)
227 if (IMG_isJPG(rw) != 0)
242 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
243 const uint32_t rmask = 0xff000000U;
244 const uint32_t gmask = 0x00ff0000U;
245 const uint32_t bmask = 0x0000ff00U;
246 const uint32_t amask = 0x000000ffU;
249 const uint32_t rmask = 0x000000ffU;
250 const uint32_t gmask = 0x0000ff00U;
251 const uint32_t bmask = 0x00ff0000U;
252 const uint32_t amask = 0xff000000U;
256 width, height, 32, rmask, gmask, bmask, amask);
const DyePalette * getSPalete() const
const DyePalette * getAPalete() const
void normalDye(uint32_t *pixels, const int bufSize) const
static void dumpSurfaceFormat(const SDL_Surface *const image)
static RenderType mUseOpenGL
static SDL_Surface * convertTo32Bit(SDL_Surface *const tmpImage)
virtual Image * loadSurface(SDL_Surface *const)
virtual SDL_Surface * create32BitSurface(int width, int height) const
static SDL_Surface * loadPng(SDL_RWops *const rw)
Image * load(SDL_RWops *const rw)
void log(const char *const log_text,...)
#define MSDL_ConvertSurface(src, fmt, flags)
#define MIMG_LoadJPG_RW(src)
#define MIMG_LoadPNG_RW(src)
#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a)
#define MSDL_FreeSurface(surface)
#define DYEPALETTEP(palette, color)
ImageHelper * imageHelper
ImageHelper * surfaceImageHelper
#define BLOCK_START(name)