(GDT): tweaked baseline image lookup.

This commit is contained in:
poddav 2022-04-29 13:07:51 +04:00
parent a6e9d6e178
commit 8f4c3f5e7d

View File

@ -27,6 +27,7 @@ using System;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
namespace GameRes.Formats.Pochette namespace GameRes.Formats.Pochette
@ -93,15 +94,21 @@ namespace GameRes.Formats.Pochette
BitmapSource BlendBaseLine (BitmapSource overlay, GdtMetaData meta) BitmapSource BlendBaseLine (BitmapSource overlay, GdtMetaData meta)
{ {
string base_name = VFS.ChangeFileName (meta.FileName, meta.BaseLine+".gdt"); string base_name = VFS.ChangeFileName (meta.FileName, meta.BaseLine);
if (!VFS.FileExists (base_name)) if (!VFS.FileExists (base_name))
return overlay; {
base_name += ".gdt";
if (!VFS.FileExists (base_name))
return overlay;
}
using (var base_file = VFS.OpenBinaryStream (base_name)) using (var base_file = VFS.OpenBinaryStream (base_name))
{ {
var base_info = ReadMetaData (base_file) as GdtMetaData; var base_info = ReadMetaData (base_file) as GdtMetaData;
if (null == base_info) if (null == base_info)
return overlay; return overlay;
var base_image = ReadBitmapSource (base_file, base_info); var base_image = ReadBitmapSource (base_file, base_info);
if (base_image.Format.BitsPerPixel < 24)
base_image = new FormatConvertedBitmap (base_image, PixelFormats.Bgr32, null, 0);
var canvas = new WriteableBitmap (base_image); var canvas = new WriteableBitmap (base_image);
int canvas_bpp = canvas.Format.BitsPerPixel; int canvas_bpp = canvas.Format.BitsPerPixel;
if (canvas_bpp != overlay.Format.BitsPerPixel) if (canvas_bpp != overlay.Format.BitsPerPixel)