(EPF): support images with less than 8 bpp.

This commit is contained in:
morkt 2023-09-07 12:13:32 +04:00
parent 11610a7f9c
commit b8095c33ba

View File

@ -48,7 +48,7 @@ namespace GameRes.Formats.Interheart
public CandyFormat () public CandyFormat ()
{ {
Signatures = new uint[] { 0x0E00, 0 }; Signatures = new uint[] { 0x0E00, 0x80020A00, 0 };
} }
public override ImageMetaData ReadMetaData (IBinaryStream file) public override ImageMetaData ReadMetaData (IBinaryStream file)
@ -82,7 +82,7 @@ namespace GameRes.Formats.Interheart
} }
else else
return null; return null;
if (info.Version != 1 && info.Version != 2 || info.BPP < 8 || info.BPP > 32) if (info.Version != 1 && info.Version != 2 || info.BPP < 1 || info.BPP > 32)
return null; return null;
return info; return info;
} }
@ -91,7 +91,7 @@ namespace GameRes.Formats.Interheart
{ {
var reader = new CandyDecoder (file, (CandyMetaData)info); var reader = new CandyDecoder (file, (CandyMetaData)info);
var pixels = reader.Unpack(); var pixels = reader.Unpack();
return ImageData.Create (info, reader.Format, reader.Palette, pixels); return ImageData.Create (info, reader.Format, reader.Palette, pixels, reader.Stride);
} }
public override void Write (Stream file, ImageData image) public override void Write (Stream file, ImageData image)
@ -113,6 +113,7 @@ namespace GameRes.Formats.Interheart
public PixelFormat Format { get; private set; } public PixelFormat Format { get; private set; }
public BitmapPalette Palette { get; private set; } public BitmapPalette Palette { get; private set; }
public int Stride { get { return m_stride; } }
public CandyDecoder (IBinaryStream input, CandyMetaData info) public CandyDecoder (IBinaryStream input, CandyMetaData info)
{ {
@ -133,6 +134,12 @@ namespace GameRes.Formats.Interheart
m_stride = m_width * 4; m_stride = m_width * 4;
Format = PixelFormats.Bgra32; Format = PixelFormats.Bgra32;
} }
else if (1 == info.BPP)
{
m_pixel_size = 1;
m_stride = (m_width + 7) / 8;
Format = PixelFormats.Indexed1;
}
else else
{ {
m_pixel_size = 1; m_pixel_size = 1;
@ -148,6 +155,8 @@ namespace GameRes.Formats.Interheart
if (m_colors > 0) if (m_colors > 0)
Palette = ReadPalette(); Palette = ReadPalette();
LzUnpack(); LzUnpack();
if (1 == m_info.BPP)
return m_output;
return RestorePixels(); return RestorePixels();
} }