Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Fixed known EPF bug #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 7 additions & 31 deletions Capricorn/Drawing/DAGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@

namespace Capricorn.Drawing
{
public enum ImageType
{
EPF,
MPF,
HPF,
SPF,
EFA,
ZP,
Tile
}

public class DAGraphics
{
Expand All @@ -28,22 +18,22 @@ static DAGraphics()

public unsafe static Bitmap RenderImage(HPFImage hpf, Palette256 palette)
{
return SimpleRender(hpf.Width, hpf.Height, hpf.RawData, palette, ImageType.HPF);
return SimpleRender(hpf.Width, hpf.Height, hpf.RawData, palette);
}
public unsafe static Bitmap RenderImage(EPFFrame epf, Palette256 palette)
{
return SimpleRender(epf.Width, epf.Height, epf.RawData, palette, ImageType.EPF);
return SimpleRender(epf.Width, epf.Height, epf.RawData, palette);
}
public unsafe static Bitmap RenderImage(MPFFrame mpf, Palette256 palette)
{
return SimpleRender(mpf.Width, mpf.Height, mpf.RawData, palette, ImageType.MPF);
return SimpleRender(mpf.Width, mpf.Height, mpf.RawData, palette);
}
public unsafe static Bitmap RenderTile(byte[] tileData, Palette256 palette)
{
return SimpleRender(Tileset.TileWidth, Tileset.TileHeight, tileData, palette, ImageType.Tile);
return SimpleRender(Tileset.TileWidth, Tileset.TileHeight, tileData, palette);
}

private unsafe static Bitmap SimpleRender(int width, int height, byte[] data, Palette256 palette, ImageType type)
private unsafe static Bitmap SimpleRender(int width, int height, byte[] data, Palette256 palette)
{
Bitmap image = new Bitmap(width, height);

Expand All @@ -55,16 +45,8 @@ private unsafe static Bitmap SimpleRender(int width, int height, byte[] data, Pa

for (int x = 0; x < bmd.Width; x++)
{
int colorIndex = 0;
if (type == ImageType.EPF)
{
colorIndex = data[x * height + y];
}
else
{
colorIndex = data[y * width + x];
}

int colorIndex = colorIndex = data[y * width + x];

if (colorIndex == 0) continue;

#region 32 Bit Render
Expand Down Expand Up @@ -115,12 +97,6 @@ private unsafe static Bitmap SimpleRender(int width, int height, byte[] data, Pa
// Unlock Bits
image.UnlockBits(bmd);

// Flip Image
if (type == ImageType.EPF)
{
image.RotateFlip(RotateFlipType.Rotate90FlipX);
}

// Return Bitmap
return image;
}
Expand Down
2 changes: 1 addition & 1 deletion Capricorn/Drawing/EPF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private static EPFImage LoadEPF(Stream stream)
reader.BaseStream.Seek(epf.tocAddress + i * 16, SeekOrigin.Begin);

#region Get Frame Header
int left = reader.ReadUInt16();
int top = reader.ReadUInt16();
int left = reader.ReadUInt16();
int right = reader.ReadUInt16();
int bottom = reader.ReadUInt16();

Expand Down