From 520e7215ba9cdd2b614bcc5a38ac233fe3e3b914 Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 11 Mar 2015 16:36:13 +0400 Subject: [PATCH] limit alpha channel values to 0xff --- ArcFormats/ImageBIP.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ArcFormats/ImageBIP.cs b/ArcFormats/ImageBIP.cs index a87d28b6..7d5509e4 100644 --- a/ArcFormats/ImageBIP.cs +++ b/ArcFormats/ImageBIP.cs @@ -83,6 +83,8 @@ namespace GameRes.Formats.PS2 input.ReadInt32(); uint w = input.ReadUInt16(); uint h = input.ReadUInt16(); + if (0 == w || 0 == h) + return null; var meta = new BipMetaData { Width = w, Height = h, BPP = 32 }; for (int i = 0; i < tile_count; ++i) { @@ -100,8 +102,6 @@ namespace GameRes.Formats.PS2 tile.Offset = input.ReadUInt32() + data_offset; meta.Tiles.Add (tile); } - if (0 == meta.Width || 0 == meta.Height || 0 == meta.Tiles.Count) - return null; return meta; } } @@ -146,6 +146,7 @@ namespace GameRes.Formats.PS2 pixels[p] = pixels[p+2]; pixels[p+2] = r; int a = 0 == alpha ? 0xff : pixels[p+3] * 0xff / 0x80; + if (a > 0xff) a = 0xff; pixels[p+3] = (byte)a; } var rect = new Int32Rect (tile.Left+x, tile.Top+y, converted.PixelWidth, converted.PixelHeight);