mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
implemented Kaguya "AO" images.
This commit is contained in:
@@ -29,7 +29,6 @@ using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Kaguya
|
||||
{
|
||||
@@ -66,6 +65,11 @@ namespace GameRes.Formats.Kaguya
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
stream.Position = 12;
|
||||
return ReadBitmapData (stream, info);
|
||||
}
|
||||
|
||||
protected ImageData ReadBitmapData (Stream stream, ImageMetaData info)
|
||||
{
|
||||
int stride = (int)info.Width*4;
|
||||
var pixels = new byte[stride*info.Height];
|
||||
for (int row = (int)info.Height-1; row >= 0; --row)
|
||||
@@ -86,21 +90,25 @@ namespace GameRes.Formats.Kaguya
|
||||
output.Write (image.Width);
|
||||
output.Write (image.Height);
|
||||
output.Write ((short)24);
|
||||
WriteBitmapData (file, image);
|
||||
}
|
||||
}
|
||||
|
||||
var bitmap = image.Bitmap;
|
||||
if (bitmap.Format != PixelFormats.Bgra32)
|
||||
{
|
||||
bitmap = new FormatConvertedBitmap (bitmap, PixelFormats.Bgra32, null, 0);
|
||||
}
|
||||
int stride = (int)image.Width * 4;
|
||||
byte[] row_data = new byte[stride];
|
||||
Int32Rect rect = new Int32Rect (0, (int)image.Height, (int)image.Width, 1);
|
||||
for (uint row = 0; row < image.Height; ++row)
|
||||
{
|
||||
--rect.Y;
|
||||
bitmap.CopyPixels (rect, row_data, stride, 0);
|
||||
output.Write (row_data);
|
||||
}
|
||||
protected void WriteBitmapData (Stream file, ImageData image)
|
||||
{
|
||||
var bitmap = image.Bitmap;
|
||||
if (bitmap.Format != PixelFormats.Bgra32)
|
||||
{
|
||||
bitmap = new FormatConvertedBitmap (bitmap, PixelFormats.Bgra32, null, 0);
|
||||
}
|
||||
int stride = (int)image.Width * 4;
|
||||
byte[] row_data = new byte[stride];
|
||||
Int32Rect rect = new Int32Rect (0, (int)image.Height, (int)image.Width, 1);
|
||||
for (uint row = 0; row < image.Height; ++row)
|
||||
{
|
||||
--rect.Y;
|
||||
bitmap.CopyPixels (rect, row_data, stride, 0);
|
||||
file.Write (row_data, 0, row_data.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user