Fix the preview for HAM files

HAM files are "true color" pictures which do have
a palette.
This commit is contained in:
Thomas Bernard 2018-02-05 11:59:26 +01:00
parent 2bfbc03cb8
commit 4c92e87d52
2 changed files with 10 additions and 5 deletions

View File

@ -390,6 +390,7 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size,
if (bpp == 0) if (bpp == 0)
bpp = 8; // default to 8bits bpp = 8; // default to 8bits
truecolor = (bpp > 8) ? 1 : 0; truecolor = (bpp > 8) ? 1 : 0;
context->bpp = bpp;
context->Pitch = width; // default context->Pitch = width; // default
context->Width = width; context->Width = width;
context->Height = height; context->Height = height;
@ -547,8 +548,6 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size,
// Extra process for truecolor images // Extra process for truecolor images
if (truecolor) if (truecolor)
{ {
//context->Is_truecolor = 1;
switch(context->Type) switch(context->Type)
{ {
case CONTEXT_MAIN_IMAGE: case CONTEXT_MAIN_IMAGE:
@ -568,8 +567,9 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size,
break; break;
case CONTEXT_PREVIEW: case CONTEXT_PREVIEW:
// Load palette // 3:3:2 "True Color" palette will be loaded lated in context->Palette
Set_palette_fake_24b(context->Palette); // There can be an image palette used to decode the true color picture
// Such as for HAM ILBM pictures
break; break;
case CONTEXT_PALETTE: case CONTEXT_PALETTE:
@ -717,7 +717,8 @@ void Load_image(T_IO_Context *context)
break; break;
case CONTEXT_PREVIEW: case CONTEXT_PREVIEW:
// nothing to do // in this context, context->Buffer_image_24b is not allocated
// pixels are drawn to context->Preview_bitmap
break; break;
case CONTEXT_SURFACE: case CONTEXT_SURFACE:
@ -923,6 +924,9 @@ void Load_image(T_IO_Context *context)
int count_unused; int count_unused;
byte unused_color[4]; byte unused_color[4];
if (context->Type == CONTEXT_PREVIEW && context->bpp > 8)
Set_palette_fake_24b(context->Palette);
count_unused=0; count_unused=0;
// Try find 4 unused colors and insert good colors there // Try find 4 unused colors and insert good colors there
for (c=255; c>=0 && count_unused<4; c--) for (c=255; c>=0 && count_unused<4; c--)

View File

@ -68,6 +68,7 @@ typedef struct
char Comment[COMMENT_SIZE+1]; char Comment[COMMENT_SIZE+1];
byte Background_transparent; byte Background_transparent;
byte Transparent_color; byte Transparent_color;
byte bpp;
/// Pixel ratio of the image /// Pixel ratio of the image
enum PIXEL_RATIO Ratio; enum PIXEL_RATIO Ratio;