@@ -258,19 +258,18 @@ void ContentFile::GetAsAnimation(std::vector<BITMAP*>& vectorToFill, int frameCo
258
258
}
259
259
}
260
260
SDL_Palette* ContentFile::DefaultPaletteToSDL () {
261
- SDL_Palette* palette = SDL_CreatePalette (256 );
262
- std::array<SDL_Color, 256 > paletteColor;
263
- PALETTE currentPalette;
264
- get_palette (currentPalette);
265
- paletteColor[0 ] = {.r = 0 , .g = 0 , .b = 0 , .a = 0 };
266
- for (size_t i = 1 ; i < paletteColor.size (); ++i) {
267
- paletteColor[i].r = currentPalette[i].r ;
268
- paletteColor[i].g = currentPalette[i].g ;
269
- paletteColor[i].b = currentPalette[i].b ;
270
- paletteColor[i].a = 255 ;
271
- }
272
- SDL_SetPaletteColors (palette, paletteColor.data (), 0 , 256 );
273
- return palette;
261
+ SDL_Palette* palette = SDL_CreatePalette (256 );
262
+ std::array<SDL_Color, 256 > paletteColor;
263
+ const PALETTE& defaultPalette = g_FrameMan.GetDefaultPalette ();
264
+ paletteColor[0 ] = {.r = 0 , .g = 0 , .b = 0 , .a = 0 };
265
+ for (size_t i = 1 ; i < paletteColor.size (); ++i) {
266
+ paletteColor[i].r = defaultPalette[i].r ;
267
+ paletteColor[i].g = defaultPalette[i].g ;
268
+ paletteColor[i].b = defaultPalette[i].b ;
269
+ paletteColor[i].a = 255 ;
270
+ }
271
+ SDL_SetPaletteColors (palette, paletteColor.data (), 0 , 256 );
272
+ return palette;
274
273
}
275
274
276
275
SDL_Surface* ContentFile::LoadImageAsSurface (int conversionMode, const std::string& dataPathToLoad) {
@@ -286,7 +285,6 @@ SDL_Surface* ContentFile::LoadImageAsSurface(int conversionMode, const std::stri
286
285
image = newImage;
287
286
bitDepth = 8 ;
288
287
} else if (bitDepth != 8 || convert8To32) {
289
-
290
288
SDL_Palette* palette = DefaultPaletteToSDL ();
291
289
if (SDL_GetPixelFormatDetails (image->format )->bits_per_pixel == 8 ) {
292
290
SDL_SetSurfacePalette (image, palette);
@@ -312,7 +310,7 @@ BITMAP* ContentFile::LoadAndReleaseBitmap(int conversionMode, const std::string&
312
310
int bitDepth = SDL_GetPixelFormatDetails (image->format )->bits_per_pixel ;
313
311
314
312
BITMAP* returnBitmap = create_bitmap_ex (bitDepth, image->w , image->h );
315
-
313
+
316
314
// allegro doesn't (always) align lines to 4byte, so copy line by line. SDL_Surface.pitch is the size in bytes per line + alignment padding.
317
315
for (int y = 0 ; y < image->h ; ++y) {
318
316
memcpy (returnBitmap->line [y], static_cast <unsigned char *>(image->pixels ) + image->pitch * y, image->w * SDL_GetPixelFormatDetails (image->format )->bytes_per_pixel );
0 commit comments