Skip to content

Commit

Permalink
fix overflow in RGBAHalfToBGRA32
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Feb 6, 2022
1 parent 6998127 commit 6665fab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TextureDecoder/Rgb/RgbConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,10 @@ public static void RGBAHalfToBGRA32(byte[] input, int width, int height, byte[]
{
for (int j = 0; j < height; j++)
{
byte r = Convert.ToByte(Math.Round(ToHalf(input, io + 0) * 255f));
byte g = Convert.ToByte(Math.Round(ToHalf(input, io + 2) * 255f));
byte b = Convert.ToByte(Math.Round(ToHalf(input, io + 4) * 255f));
byte a = Convert.ToByte(Math.Round(ToHalf(input, io + 6) * 255f));
byte r = ClampByte(ToHalf(input, io + 0) * 255f);
byte g = ClampByte(ToHalf(input, io + 2) * 255f);
byte b = ClampByte(ToHalf(input, io + 4) * 255f);
byte a = ClampByte(ToHalf(input, io + 6) * 255f);
output[oo + 0] = b; // b
output[oo + 1] = g; // g
output[oo + 2] = r; // r
Expand Down

0 comments on commit 6665fab

Please sign in to comment.