mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
implemented SYG images.
This commit is contained in:
parent
4b945bc46a
commit
7347e5fac5
@ -321,6 +321,7 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WebP\Lossless.cs" />
|
||||
<Compile Include="WestVision\ImageSYG.cs" />
|
||||
<Compile Include="Will\ArcPNA.cs" />
|
||||
<Compile Include="Will\ArcPulltop.cs" />
|
||||
<Compile Include="Xuse\ArcBIN.cs" />
|
||||
@ -651,6 +652,7 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Strings\arcStrings.ru-RU.resx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>perl "$(SolutionDir)inc-revision.pl" "$(ProjectPath)" $(ConfigurationName)
|
||||
|
97
ArcFormats/WestVision/ImageSYG.cs
Normal file
97
ArcFormats/WestVision/ImageSYG.cs
Normal file
@ -0,0 +1,97 @@
|
||||
//! \file ImageSYG.cs
|
||||
//! \date Sun Jun 05 19:14:11 2016
|
||||
//! \brief West Vision 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.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.WestVision
|
||||
{
|
||||
internal class SygMetaData : ImageMetaData
|
||||
{
|
||||
public uint AlphaOffset;
|
||||
}
|
||||
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class SygFormat : ImageFormat
|
||||
{
|
||||
public override string Tag { get { return "SYG"; } }
|
||||
public override string Description { get { return "West Vision image format"; } }
|
||||
public override uint Signature { get { return 0x47595324; } } // '$SYG'
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
var header = new byte[0x20];
|
||||
if (header.Length != stream.Read (header, 0, header.Length))
|
||||
return null;
|
||||
uint alpha_offset = LittleEndian.ToUInt32 (header, 0x1C);
|
||||
return new SygMetaData
|
||||
{
|
||||
Width = LittleEndian.ToUInt32 (header, 0x10),
|
||||
Height = LittleEndian.ToUInt32 (header, 0x14),
|
||||
BPP = 0 == alpha_offset ? 24 : 32,
|
||||
AlphaOffset = alpha_offset,
|
||||
};
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
var meta = (SygMetaData)info;
|
||||
int pixel_count = (int)meta.Width * (int)meta.Height;
|
||||
var pixels = new byte[pixel_count * 3];
|
||||
stream.Position = 0x20;
|
||||
if (pixels.Length != stream.Read (pixels, 0, pixels.Length))
|
||||
throw new EndOfStreamException ("Unexpected end of file");
|
||||
var format = PixelFormats.Bgr24;
|
||||
if (meta.AlphaOffset != 0)
|
||||
{
|
||||
var alpha = new byte[pixel_count];
|
||||
stream.Position = 0x20 + meta.AlphaOffset;
|
||||
if (alpha.Length == stream.Read (alpha, 0, alpha.Length))
|
||||
{
|
||||
var output = new byte[pixel_count * 4];
|
||||
int dst = 0;
|
||||
int src = 0;
|
||||
for (int i = 0; i < pixel_count; ++i)
|
||||
{
|
||||
output[dst++] = pixels[src++];
|
||||
output[dst++] = pixels[src++];
|
||||
output[dst++] = pixels[src++];
|
||||
output[dst++] = alpha[i];
|
||||
}
|
||||
pixels = output;
|
||||
format = PixelFormats.Bgra32;
|
||||
}
|
||||
}
|
||||
return ImageData.Create (info, format, null, pixels);
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
throw new System.NotImplementedException ("SygFormat.Write not implemented");
|
||||
}
|
||||
}
|
||||
}
|
@ -863,6 +863,10 @@ Tsujidou-san no Virgin Road<br/>
|
||||
<tr><td>*.pak</td><td><tt>PACK</tt></td><td>No</td><td>Studio Nekopunch</td><td>
|
||||
Uso x Mote ~Usonko Motemote-shon~<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.syg</td><td><tt>$SYG</tt></td><td>No</td><td>West Vision</td><td>
|
||||
Chijoku Yuugi<br/>
|
||||
Taiiku Souko ~Shoujotachi no Sange~<br/>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p><a name="note-1" class="footnote">1</a> Non-encrypted only</p>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user