Mercurial > hg > dmlib
comparison tools/64vw.c @ 1730:881a3fc421d8
Use the default C64 palette whenever we need it, but make it possible to override it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 08 Jun 2018 22:03:19 +0300 |
parents | f4015f6cb173 |
children | 5e928618fdc8 |
comparison
equal
deleted
inserted
replaced
1729:f4015f6cb173 | 1730:881a3fc421d8 |
---|---|
208 int dmDecodeC64Image(const DMC64Image *cimage, const DMC64ImageFormat *fmt, SDL_Surface *surf) | 208 int dmDecodeC64Image(const DMC64Image *cimage, const DMC64ImageFormat *fmt, SDL_Surface *surf) |
209 { | 209 { |
210 DMImage bmap; | 210 DMImage bmap; |
211 int ret; | 211 int ret; |
212 | 212 |
213 bmap.size = surf->pitch * surf->h; | 213 memset(&bmap, 0, sizeof(bmap)); |
214 bmap.data = surf->pixels; | 214 bmap.size = surf->pitch * surf->h; |
215 bmap.pitch = surf->pitch; | 215 bmap.data = surf->pixels; |
216 bmap.width = surf->w; | 216 bmap.pitch = surf->pitch; |
217 bmap.height = surf->h; | 217 bmap.width = surf->w; |
218 bmap.height = surf->h; | |
219 bmap.ncolors = C64_NCOLORS; | |
220 bmap.constpal = TRUE; | |
221 bmap.pal = dmDefaultC64Palette; | |
218 | 222 |
219 if (fmt->convertFrom != NULL) | 223 if (fmt->convertFrom != NULL) |
220 ret = fmt->convertFrom(&bmap, cimage, fmt); | 224 ret = fmt->convertFrom(&bmap, cimage, fmt); |
221 else | 225 else |
222 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); | 226 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); |
227 | |
228 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors); | |
223 | 229 |
224 return ret; | 230 return ret; |
225 } | 231 } |
226 | 232 |
227 | 233 |
483 { | 489 { |
484 dmErrorMsg("Could not allocate surface.\n"); | 490 dmErrorMsg("Could not allocate surface.\n"); |
485 goto exit; | 491 goto exit; |
486 } | 492 } |
487 | 493 |
488 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *)dmDefaultC64Palette, 0, C64_NCOLORS); | |
489 | 494 |
490 if (texture != NULL) | 495 if (texture != NULL) |
491 SDL_DestroyTexture(texture); | 496 SDL_DestroyTexture(texture); |
492 | 497 |
493 if ((texture = SDL_CreateTextureFromSurface(renderer, surf)) == NULL) | 498 if ((texture = SDL_CreateTextureFromSurface(renderer, surf)) == NULL) |