(PnaDecoder): derive from BinaryImageDecoder.

This commit is contained in:
morkt 2016-12-23 23:15:21 +04:00
parent 543fad3fb6
commit 882f3ec461

View File

@ -91,32 +91,16 @@ namespace GameRes.Formats.Will
} }
} }
internal sealed class PnaDecoder : IImageDecoder internal sealed class PnaDecoder : BinaryImageDecoder
{ {
IBinaryStream m_input; public PnaDecoder (IBinaryStream input, ImageMetaData info) : base (input, info)
ImageMetaData m_info; {
ImageData m_image; }
public Stream Source { get { m_input.Position = 0; return m_input.AsStream; } } protected override ImageData GetImageData ()
public ImageFormat SourceFormat { get { return null; } }
public ImageMetaData Info { get { return m_info; } }
public ImageData Image
{
get
{
if (null == m_image)
{ {
var pixels = ReadPixels(); var pixels = ReadPixels();
m_image = ImageData.Create (m_info, PixelFormats.Bgra32, null, pixels); return ImageData.Create (Info, PixelFormats.Bgra32, null, pixels);
}
return m_image;
}
}
public PnaDecoder (IBinaryStream input, ImageMetaData info)
{
m_input = input;
m_info = info;
} }
byte[] ReadPixels () byte[] ReadPixels ()
@ -146,15 +130,5 @@ namespace GameRes.Formats.Will
} }
return pixels; return pixels;
} }
bool m_disposed = false;
public void Dispose ()
{
if (!m_disposed)
{
m_input.Dispose();
m_disposed = true;
}
}
} }
} }