mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
implemented GR3 image format.
This commit is contained in:
@@ -97,6 +97,7 @@
|
|||||||
<Compile Include="KiriKiri\ChainReactionCrypt.cs" />
|
<Compile Include="KiriKiri\ChainReactionCrypt.cs" />
|
||||||
<Compile Include="Liar\ImageLIM.cs" />
|
<Compile Include="Liar\ImageLIM.cs" />
|
||||||
<Compile Include="MnoViolet\ImageDIF.cs" />
|
<Compile Include="MnoViolet\ImageDIF.cs" />
|
||||||
|
<Compile Include="Nexas\ImageGRP.cs" />
|
||||||
<Compile Include="NitroPlus\ArcNPK.cs" />
|
<Compile Include="NitroPlus\ArcNPK.cs" />
|
||||||
<Compile Include="NonColor\ArcDAT.cs" />
|
<Compile Include="NonColor\ArcDAT.cs" />
|
||||||
<Compile Include="Crc64.cs" />
|
<Compile Include="Crc64.cs" />
|
||||||
@@ -276,7 +277,7 @@
|
|||||||
<Compile Include="MnoViolet\ArcMnoViolet.cs" />
|
<Compile Include="MnoViolet\ArcMnoViolet.cs" />
|
||||||
<Compile Include="FC01\ArcMRG.cs" />
|
<Compile Include="FC01\ArcMRG.cs" />
|
||||||
<Compile Include="ArcNEKO.cs" />
|
<Compile Include="ArcNEKO.cs" />
|
||||||
<Compile Include="ArcNexas.cs" />
|
<Compile Include="Nexas\ArcPAC.cs" />
|
||||||
<Compile Include="NitroPlus\ArcNitro.cs" />
|
<Compile Include="NitroPlus\ArcNitro.cs" />
|
||||||
<Compile Include="Entis\ArcNOA.cs" />
|
<Compile Include="Entis\ArcNOA.cs" />
|
||||||
<Compile Include="NitroPlus\ArcNPA.cs" />
|
<Compile Include="NitroPlus\ArcNPA.cs" />
|
||||||
|
|||||||
143
ArcFormats/Nexas/ImageGRP.cs
Normal file
143
ArcFormats/Nexas/ImageGRP.cs
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
//! \file ImageGRP.cs
|
||||||
|
//! \date Fri May 20 20:30:01 2016
|
||||||
|
//! \brief NeXAS GRP image format.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 by morkt
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.Composition;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using GameRes.Utility;
|
||||||
|
|
||||||
|
namespace GameRes.Formats.NeXAS
|
||||||
|
{
|
||||||
|
internal class GrpMetaData : ImageMetaData
|
||||||
|
{
|
||||||
|
public int UnpackedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Export(typeof(ImageFormat))]
|
||||||
|
public class GrpFormat : ImageFormat
|
||||||
|
{
|
||||||
|
public override string Tag { get { return "GR3"; } }
|
||||||
|
public override string Description { get { return "NeXAS engine image format"; } }
|
||||||
|
public override uint Signature { get { return 0x18335247; } }
|
||||||
|
|
||||||
|
public GrpFormat ()
|
||||||
|
{
|
||||||
|
Extensions = new string[] { "grp" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ImageMetaData ReadMetaData (Stream stream)
|
||||||
|
{
|
||||||
|
var header = new byte[0x11];
|
||||||
|
if (header.Length != stream.Read (header, 0, header.Length))
|
||||||
|
return null;
|
||||||
|
return new GrpMetaData
|
||||||
|
{
|
||||||
|
Width = LittleEndian.ToUInt32 (header, 5),
|
||||||
|
Height = LittleEndian.ToUInt32 (header, 9),
|
||||||
|
BPP = LittleEndian.ToUInt16 (header, 3),
|
||||||
|
UnpackedSize = LittleEndian.ToInt32 (header, 0xD),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||||
|
{
|
||||||
|
using (var reader = new GrpReader (stream, (GrpMetaData)info))
|
||||||
|
{
|
||||||
|
reader.Unpack();
|
||||||
|
return ImageData.Create (info, reader.Format, null, reader.Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write (Stream file, ImageData image)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException ("GrpFormat.Write not implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class GrpReader : IDisposable
|
||||||
|
{
|
||||||
|
BinaryReader m_input;
|
||||||
|
byte[] m_output;
|
||||||
|
|
||||||
|
public byte[] Data { get { return m_output; } }
|
||||||
|
public PixelFormat Format { get; private set; }
|
||||||
|
|
||||||
|
public GrpReader (Stream input, GrpMetaData info)
|
||||||
|
{
|
||||||
|
m_input = new ArcView.Reader (input);
|
||||||
|
m_output = new byte[info.UnpackedSize];
|
||||||
|
if (24 == info.BPP)
|
||||||
|
Format = PixelFormats.Bgr24;
|
||||||
|
else if (32 == info.BPP)
|
||||||
|
Format = PixelFormats.Bgr32;
|
||||||
|
else
|
||||||
|
throw new NotSupportedException ("Not supported GRP image color depth");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unpack ()
|
||||||
|
{
|
||||||
|
m_input.BaseStream.Position = 0x11;
|
||||||
|
int ctl_length = (m_input.ReadInt32() + 7) / 8;
|
||||||
|
var ctl_bytes = m_input.ReadBytes (ctl_length);
|
||||||
|
m_input.ReadInt32();
|
||||||
|
using (var ctl_mem = new MemoryStream (ctl_bytes))
|
||||||
|
using (var bits = new LsbBitStream (ctl_mem))
|
||||||
|
{
|
||||||
|
int dst = 0;
|
||||||
|
while (dst < m_output.Length)
|
||||||
|
{
|
||||||
|
int bit = bits.GetNextBit();
|
||||||
|
if (-1 == bit)
|
||||||
|
break;
|
||||||
|
if (0 == bit)
|
||||||
|
{
|
||||||
|
m_output[dst++] = m_input.ReadByte();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int offset = m_input.ReadUInt16();
|
||||||
|
int count = (offset & 7) + 1;
|
||||||
|
offset = (offset >> 3) + 1;
|
||||||
|
Binary.CopyOverlapped (m_output, dst - offset, dst, count);
|
||||||
|
dst += count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
bool _disposed = false;
|
||||||
|
public void Dispose ()
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
m_input.Dispose();
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -154,12 +154,13 @@ Binary Pot<br/>
|
|||||||
Tsukihime<br/>
|
Tsukihime<br/>
|
||||||
Umineko<br/>
|
Umineko<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>*.pac</td><td><tt>PAC</tt></td><td>No</td><td>NeXAS</td><td>
|
<tr><td>*.pac</td><td><tt>PAC</tt></td><td>No</td><td rowspan="2">NeXAS</td><td rowspan="2">
|
||||||
Baldr Sky DiveX<br/>
|
Baldr Sky DiveX<br/>
|
||||||
Fossette ~Cafe au Le Ciel Bleu~<br/>
|
Fossette ~Cafe au Le Ciel Bleu~<br/>
|
||||||
Jinki Extend Re:Vision<br/>
|
Jinki Extend Re:Vision<br/>
|
||||||
Maji de Watashi ni Koishinasai!<br/>
|
Maji de Watashi ni Koishinasai!<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
<tr><td>*.grp</td><td><tt>GR3</tt></td><td>No</td></tr>
|
||||||
<tr class="odd"><td>*.pac</td><td><tt>PAC1</tt></td><td>No</td><td rowspan="2">RAGE</td><td rowspan="2">
|
<tr class="odd"><td>*.pac</td><td><tt>PAC1</tt></td><td>No</td><td rowspan="2">RAGE</td><td rowspan="2">
|
||||||
Brightia Plus<br/>
|
Brightia Plus<br/>
|
||||||
Hana Hiraku<br/>
|
Hana Hiraku<br/>
|
||||||
|
|||||||
Reference in New Issue
Block a user