mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
renamed some ImageDecoder properties and classes.
This commit is contained in:
parent
2c06c1cbcd
commit
c771b13d4e
@ -94,11 +94,11 @@ namespace GameRes.Formats.CatSystem
|
|||||||
protected int m_pixel_size;
|
protected int m_pixel_size;
|
||||||
protected ImageData m_image;
|
protected ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { return m_input.AsStream; } }
|
public Stream Source { get { return m_input.AsStream; } }
|
||||||
public int Stride { get; protected set; }
|
public ImageFormat SourceFormat { get { return null; } }
|
||||||
public ImageFormat Format { get { return null; } }
|
|
||||||
public ImageMetaData Info { get { return m_info; } }
|
public ImageMetaData Info { get { return m_info; } }
|
||||||
public virtual ImageData Image { get { throw new NotImplementedException(); } }
|
public virtual ImageData Image { get { throw new NotImplementedException(); } }
|
||||||
|
public int Stride { get; protected set; }
|
||||||
|
|
||||||
protected HgReader (IBinaryStream input, HgMetaData info)
|
protected HgReader (IBinaryStream input, HgMetaData info)
|
||||||
{
|
{
|
||||||
@ -112,12 +112,12 @@ namespace GameRes.Formats.CatSystem
|
|||||||
{
|
{
|
||||||
var ctl_offset = data_offset + data_packed;
|
var ctl_offset = data_offset + data_packed;
|
||||||
var data = new byte[data_unpacked];
|
var data = new byte[data_unpacked];
|
||||||
using (var z = new StreamRegion (Input, data_offset, data_packed, true))
|
using (var z = new StreamRegion (Source, data_offset, data_packed, true))
|
||||||
using (var data_in = new ZLibStream (z, CompressionMode.Decompress))
|
using (var data_in = new ZLibStream (z, CompressionMode.Decompress))
|
||||||
if (data.Length != data_in.Read (data, 0, data.Length))
|
if (data.Length != data_in.Read (data, 0, data.Length))
|
||||||
throw new EndOfStreamException();
|
throw new EndOfStreamException();
|
||||||
|
|
||||||
using (var z = new StreamRegion (Input, ctl_offset, ctl_packed, true))
|
using (var z = new StreamRegion (Source, ctl_offset, ctl_packed, true))
|
||||||
using (var ctl_in = new ZLibStream (z, CompressionMode.Decompress))
|
using (var ctl_in = new ZLibStream (z, CompressionMode.Decompress))
|
||||||
using (var bits = new LsbBitStream (ctl_in))
|
using (var bits = new LsbBitStream (ctl_in))
|
||||||
{
|
{
|
||||||
@ -258,7 +258,7 @@ namespace GameRes.Formats.CatSystem
|
|||||||
|
|
||||||
public byte[] Unpack ()
|
public byte[] Unpack ()
|
||||||
{
|
{
|
||||||
Input.Position = m_info.HeaderSize;
|
Source.Position = m_info.HeaderSize;
|
||||||
var img_type = m_input.ReadBytes (8);
|
var img_type = m_input.ReadBytes (8);
|
||||||
if (Binary.AsciiEqual (img_type, "img0000\0"))
|
if (Binary.AsciiEqual (img_type, "img0000\0"))
|
||||||
return UnpackImg0000();
|
return UnpackImg0000();
|
||||||
@ -271,7 +271,7 @@ namespace GameRes.Formats.CatSystem
|
|||||||
byte[] UnpackImg0000 ()
|
byte[] UnpackImg0000 ()
|
||||||
{
|
{
|
||||||
Flipped = true;
|
Flipped = true;
|
||||||
Input.Position = m_info.HeaderSize+0x18;
|
Source.Position = m_info.HeaderSize+0x18;
|
||||||
int packed_data_size = m_input.ReadInt32();
|
int packed_data_size = m_input.ReadInt32();
|
||||||
int data_size = m_input.ReadInt32();
|
int data_size = m_input.ReadInt32();
|
||||||
int packed_ctl_size = m_input.ReadInt32();
|
int packed_ctl_size = m_input.ReadInt32();
|
||||||
@ -284,8 +284,8 @@ namespace GameRes.Formats.CatSystem
|
|||||||
Flipped = false;
|
Flipped = false;
|
||||||
m_input.ReadInt32();
|
m_input.ReadInt32();
|
||||||
var jpeg_size = m_input.ReadInt32();
|
var jpeg_size = m_input.ReadInt32();
|
||||||
long next_section = Input.Position + jpeg_size;
|
long next_section = Source.Position + jpeg_size;
|
||||||
var decoder = new JpegBitmapDecoder (Input,
|
var decoder = new JpegBitmapDecoder (Source,
|
||||||
BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||||
var frame = decoder.Frames[0];
|
var frame = decoder.Frames[0];
|
||||||
if (frame.Format.BitsPerPixel < 24)
|
if (frame.Format.BitsPerPixel < 24)
|
||||||
@ -313,7 +313,7 @@ namespace GameRes.Formats.CatSystem
|
|||||||
return output;
|
return output;
|
||||||
m_input.Seek (8, SeekOrigin.Current);
|
m_input.Seek (8, SeekOrigin.Current);
|
||||||
int alpha_size = m_input.ReadInt32();
|
int alpha_size = m_input.ReadInt32();
|
||||||
using (var alpha_in = new StreamRegion (Input, Input.Position+4, alpha_size, true))
|
using (var alpha_in = new StreamRegion (Source, Source.Position+4, alpha_size, true))
|
||||||
using (var alpha = new ZLibStream (alpha_in, CompressionMode.Decompress))
|
using (var alpha = new ZLibStream (alpha_in, CompressionMode.Decompress))
|
||||||
{
|
{
|
||||||
for (int i = 3; i < output.Length; i += 4)
|
for (int i = 3; i < output.Length; i += 4)
|
||||||
|
@ -240,7 +240,7 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
input.Position = 0;
|
input.Position = 0;
|
||||||
return new ImageStreamDecoder (input);
|
return new ImageFormatDecoder (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint DecodeDecimal (ArcView file, long offset)
|
uint DecodeDecimal (ArcView file, long offset)
|
||||||
@ -409,7 +409,7 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
if (id == scheme.Value2)
|
if (id == scheme.Value2)
|
||||||
return new AImageReader (input, scheme);
|
return new AImageReader (input, scheme);
|
||||||
input.Position = 0;
|
input.Position = 0;
|
||||||
return new ImageStreamDecoder (input);
|
return new ImageFormatDecoder (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] ReadToc (string toc_name)
|
byte[] ReadToc (string toc_name)
|
||||||
|
@ -52,9 +52,9 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
AImageScheme m_scheme;
|
AImageScheme m_scheme;
|
||||||
ImageData m_image;
|
ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { m_input.Position = 0; return m_input.AsStream; } }
|
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 ImageMetaData Info { get { return m_info; } }
|
||||||
public ImageFormat Format { get { return null; } }
|
|
||||||
|
|
||||||
public ImageData Image
|
public ImageData Image
|
||||||
{
|
{
|
||||||
|
@ -212,8 +212,8 @@ namespace GameRes.Formats.Kaguya
|
|||||||
protected override ImageData GetImageData ()
|
protected override ImageData GetImageData ()
|
||||||
{
|
{
|
||||||
m_input.Position = 0x14;
|
m_input.Position = 0x14;
|
||||||
int stride = info.BPP/8*(int)Info.Width;
|
int stride = Info.BPP/8*(int)Info.Width;
|
||||||
var pixels = m_input.ReadBytes (stride*(int)info.Height);
|
var pixels = m_input.ReadBytes (stride*(int)Info.Height);
|
||||||
return ImageData.CreateFlipped (Info, GetFormat(), null, pixels, stride);
|
return ImageData.CreateFlipped (Info, GetFormat(), null, pixels, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Windows.Media;
|
||||||
using GameRes.Compression;
|
using GameRes.Compression;
|
||||||
|
|
||||||
namespace GameRes.Formats.Musica
|
namespace GameRes.Formats.Musica
|
||||||
@ -96,8 +97,8 @@ namespace GameRes.Formats.Musica
|
|||||||
ImageMetaData m_info;
|
ImageMetaData m_info;
|
||||||
ImageData m_image;
|
ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { return m_input; } }
|
public Stream Source { get { return m_input; } }
|
||||||
public ImageFormat Format { get { return null; } }
|
public ImageFormat SourceFormat { get { return null; } }
|
||||||
public ImageMetaData Info { get { return m_info; } }
|
public ImageMetaData Info { get { return m_info; } }
|
||||||
public ImageData Image
|
public ImageData Image
|
||||||
{
|
{
|
||||||
|
@ -95,9 +95,9 @@ namespace GameRes.Formats.ShiinaRio
|
|||||||
ImageMetaData m_info;
|
ImageMetaData m_info;
|
||||||
ImageData m_image;
|
ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { m_input.Position = 0; return m_input.AsStream; } }
|
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 ImageMetaData Info { get { return m_info; } }
|
||||||
public ImageFormat Format { get { return null; } }
|
|
||||||
|
|
||||||
public ImageData Image
|
public ImageData Image
|
||||||
{
|
{
|
||||||
|
@ -310,14 +310,14 @@ namespace GARbro.GUI
|
|||||||
{
|
{
|
||||||
using (var decoder = arc.OpenImage (entry))
|
using (var decoder = arc.OpenImage (entry))
|
||||||
{
|
{
|
||||||
var src_format = decoder.Format; // could be null
|
var src_format = decoder.SourceFormat; // could be null
|
||||||
string target_ext = target_format.Extensions.FirstOrDefault() ?? "";
|
string target_ext = target_format.Extensions.FirstOrDefault() ?? "";
|
||||||
string outname = FindUniqueFileName (entry.Name, target_ext);
|
string outname = FindUniqueFileName (entry.Name, target_ext);
|
||||||
if (src_format == target_format)
|
if (src_format == target_format)
|
||||||
{
|
{
|
||||||
// source format is the same as a target, copy file as is
|
// source format is the same as a target, copy file as is
|
||||||
using (var output = ArchiveFormat.CreateFile (outname))
|
using (var output = ArchiveFormat.CreateFile (outname))
|
||||||
decoder.Input.CopyTo (output);
|
decoder.Source.CopyTo (output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImageData image = decoder.Image;
|
ImageData image = decoder.Image;
|
||||||
|
@ -51,5 +51,5 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion ("1.2.20.1412")]
|
[assembly: AssemblyVersion ("1.2.20.1503")]
|
||||||
[assembly: AssemblyFileVersion ("1.2.20.1412")]
|
[assembly: AssemblyFileVersion ("1.2.20.1503")]
|
||||||
|
@ -730,7 +730,7 @@ namespace GameRes
|
|||||||
return arc_fs.Source.OpenImage (entry);
|
return arc_fs.Source.OpenImage (entry);
|
||||||
|
|
||||||
var input = fs.OpenBinaryStream (entry);
|
var input = fs.OpenBinaryStream (entry);
|
||||||
return new ImageStreamDecoder (input);
|
return new ImageFormatDecoder (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream OpenStream (string filename)
|
public static Stream OpenStream (string filename)
|
||||||
|
@ -203,7 +203,7 @@ namespace GameRes
|
|||||||
public virtual IImageDecoder OpenImage (ArcFile arc, Entry entry)
|
public virtual IImageDecoder OpenImage (ArcFile arc, Entry entry)
|
||||||
{
|
{
|
||||||
var input = arc.OpenBinaryEntry (entry);
|
var input = arc.OpenBinaryEntry (entry);
|
||||||
return new ImageStreamDecoder (input);
|
return new ImageFormatDecoder (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -30,12 +30,12 @@ namespace GameRes
|
|||||||
{
|
{
|
||||||
public interface IImageDecoder : IDisposable
|
public interface IImageDecoder : IDisposable
|
||||||
{
|
{
|
||||||
Stream Input { get; }
|
Stream Source { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Underlying image format or null if image is not represented by any format.
|
/// Underlying image format or null if image is not represented by any format.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ImageFormat Format { get; }
|
ImageFormat SourceFormat { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Image parameters.
|
/// Image parameters.
|
||||||
@ -48,14 +48,13 @@ namespace GameRes
|
|||||||
ImageData Image { get; }
|
ImageData Image { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ImageStreamDecoder : IImageDecoder
|
public sealed class ImageFormatDecoder : IImageDecoder
|
||||||
{
|
{
|
||||||
IBinaryStream m_file;
|
IBinaryStream m_file;
|
||||||
ImageData m_image;
|
ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { m_file.Position = 0; return m_file.AsStream; } }
|
public Stream Source { get { m_file.Position = 0; return m_file.AsStream; } }
|
||||||
|
public ImageFormat SourceFormat { get; private set; }
|
||||||
public ImageFormat Format { get; private set; }
|
|
||||||
public ImageMetaData Info { get; private set; }
|
public ImageMetaData Info { get; private set; }
|
||||||
|
|
||||||
public ImageData Image
|
public ImageData Image
|
||||||
@ -65,19 +64,19 @@ namespace GameRes
|
|||||||
if (null == m_image)
|
if (null == m_image)
|
||||||
{
|
{
|
||||||
m_file.Position = 0;
|
m_file.Position = 0;
|
||||||
m_image = Format.Read (m_file, Info);
|
m_image = SourceFormat.Read (m_file, Info);
|
||||||
}
|
}
|
||||||
return m_image;
|
return m_image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageStreamDecoder (IBinaryStream file)
|
public ImageFormatDecoder (IBinaryStream file)
|
||||||
{
|
{
|
||||||
m_file = file;
|
m_file = file;
|
||||||
var format = ImageFormat.FindFormat (file);
|
var format = ImageFormat.FindFormat (file);
|
||||||
if (null == format)
|
if (null == format)
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
Format = format.Item1;
|
SourceFormat = format.Item1;
|
||||||
Info = format.Item2;
|
Info = format.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +96,8 @@ namespace GameRes
|
|||||||
protected IBinaryStream m_input;
|
protected IBinaryStream m_input;
|
||||||
protected ImageData m_image;
|
protected ImageData m_image;
|
||||||
|
|
||||||
public Stream Input { get { m_input.Position = 0; return m_input.AsStream; } }
|
public Stream Source { get { m_input.Position = 0; return m_input.AsStream; } }
|
||||||
public ImageFormat Format { get { return null; } }
|
public ImageFormat SourceFormat { get { return null; } }
|
||||||
public ImageMetaData Info { get; protected set; }
|
public ImageMetaData Info { get; protected set; }
|
||||||
public ImageData Image
|
public ImageData Image
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user