From 882f3ec461510f6aa24803689b66ab3110326958 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 23 Dec 2016 23:15:21 +0400 Subject: [PATCH] (PnaDecoder): derive from BinaryImageDecoder. --- ArcFormats/Will/ArcPNA.cs | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/ArcFormats/Will/ArcPNA.cs b/ArcFormats/Will/ArcPNA.cs index ee493f48..35fa6d12 100644 --- a/ArcFormats/Will/ArcPNA.cs +++ b/ArcFormats/Will/ArcPNA.cs @@ -91,32 +91,16 @@ namespace GameRes.Formats.Will } } - internal sealed class PnaDecoder : IImageDecoder + internal sealed class PnaDecoder : BinaryImageDecoder { - IBinaryStream m_input; - ImageMetaData m_info; - ImageData m_image; - - public Stream Source { get { m_input.Position = 0; return m_input.AsStream; } } - public ImageFormat SourceFormat { get { return null; } } - public ImageMetaData Info { get { return m_info; } } - public ImageData Image + public PnaDecoder (IBinaryStream input, ImageMetaData info) : base (input, info) { - get - { - if (null == m_image) - { - var pixels = ReadPixels(); - m_image = ImageData.Create (m_info, PixelFormats.Bgra32, null, pixels); - } - return m_image; - } } - public PnaDecoder (IBinaryStream input, ImageMetaData info) + protected override ImageData GetImageData () { - m_input = input; - m_info = info; + var pixels = ReadPixels(); + return ImageData.Create (Info, PixelFormats.Bgra32, null, pixels); } byte[] ReadPixels () @@ -146,15 +130,5 @@ namespace GameRes.Formats.Will } return pixels; } - - bool m_disposed = false; - public void Dispose () - { - if (!m_disposed) - { - m_input.Dispose(); - m_disposed = true; - } - } } }