mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
(TINK): work-around for PNG images.
This commit is contained in:
parent
6904afe2f1
commit
6a4a9a3c46
@ -2,7 +2,7 @@
|
|||||||
//! \date Fri Jun 17 18:49:04 2016
|
//! \date Fri Jun 17 18:49:04 2016
|
||||||
//! \brief Tinker Bell encrypted image file.
|
//! \brief Tinker Bell encrypted image file.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2016-2017 by morkt
|
// Copyright (C) 2016-2022 by morkt
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
@ -28,6 +28,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using GameRes.Utility;
|
||||||
|
|
||||||
namespace GameRes.Formats.Cyberworks
|
namespace GameRes.Formats.Cyberworks
|
||||||
{
|
{
|
||||||
@ -145,11 +146,17 @@ namespace GameRes.Formats.Cyberworks
|
|||||||
{
|
{
|
||||||
var size_buf = new byte[4];
|
var size_buf = new byte[4];
|
||||||
input.Read (size_buf, 0 , 4);
|
input.Read (size_buf, 0 , 4);
|
||||||
if ('c' == type)
|
int png_size = BigEndian.ToInt32 (size_buf, 0);
|
||||||
input.ReadByte();
|
BitmapSource frame;
|
||||||
var decoder = new PngBitmapDecoder (input, BitmapCreateOptions.None,
|
// work-around for possible extra padding before PNG data
|
||||||
BitmapCacheOption.OnLoad);
|
using (var membuf = new MemoryStream (png_size+4))
|
||||||
BitmapSource frame = decoder.Frames[0];
|
{
|
||||||
|
input.CopyTo (membuf);
|
||||||
|
membuf.Seek (-png_size, SeekOrigin.End);
|
||||||
|
var decoder = new PngBitmapDecoder (membuf, BitmapCreateOptions.None,
|
||||||
|
BitmapCacheOption.OnLoad);
|
||||||
|
frame = decoder.Frames[0];
|
||||||
|
}
|
||||||
Info.Width = (uint)frame.PixelWidth;
|
Info.Width = (uint)frame.PixelWidth;
|
||||||
Info.Height = (uint)frame.PixelHeight;
|
Info.Height = (uint)frame.PixelHeight;
|
||||||
if (frame.Format.BitsPerPixel != 32)
|
if (frame.Format.BitsPerPixel != 32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user