Skip to content

Commit

Permalink
Refactor 8-bit image conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tvasenin committed Nov 28, 2017
1 parent 3f914af commit 84182ca
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Pre2/AssetConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,12 @@ private static void ConvertIndex8WithPalette(string resource)
{
string destFilename = Path.Combine(CacheDir, resource + ".png");
byte[] data = UnpackSqz(resource);
ImageInfo imi = new ImageInfo(320, 200, 8, false, false, true);
const int numPaletteEntries = 256;
byte[] pal = new byte[numPaletteEntries * 3];
byte[] indexBytes = new byte[imi.BytesPerRow * imi.Rows];
using (Stream input = new MemoryStream(data))
using (BinaryReader br = new BinaryReader(new MemoryStream(data, false)))
{
input.Read(pal, 0, pal.Length);
input.Read(indexBytes, 0, indexBytes.Length);
byte[] pal = br.ReadBytes(256 * 3);
byte[] indexBytes = br.ReadBytes(BackgroundInfo.W * BackgroundInfo.H); // 8 bpp
WritePng8(destFilename, indexBytes, pal, BackgroundInfo);
}
WritePng8(destFilename, indexBytes, pal, BackgroundInfo);
}

private static void ConvertIndex4(string resource, byte[] pal, SpriteInfo imageInfo)
Expand Down

0 comments on commit 84182ca

Please sign in to comment.