Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
QOI_OP_LUMA decoding fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Delofon committed May 15, 2022
1 parent 31daae4 commit 2b9fcde
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions QOIDecoder/DecoderProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ static void Main(string[] args)
case (byte)Tags.QOI_OP_LUMA >> 6:
{
byte b2 = byteData[++i];
int diff_green = ((byte)(b1 << 2) >> 6) - 32;

int diff_green = ((byte)(b1 << 2) >> 2) - 32;
int dr_dg = (byte)(b2 >> 4) - 8;
int db_dg = ((byte)(b2 << 4) >> 4) - 8;
int cur_g = (byte)(previous.g + diff_green) % 256;
int cur_r = (byte)(dr_dg + diff_green + previous.r) % 256;
int cur_b = (byte)(db_dg + diff_green + previous.b) % 256;
Colour newCol = new Colour((byte)cur_r, (byte)cur_g, (byte)cur_b, previous.a);

byte cur_g = (byte)(previous.g + diff_green);
byte cur_r = (byte)(dr_dg + diff_green + previous.r);
byte cur_b = (byte)(db_dg + diff_green + previous.b);
Colour newCol = new Colour(cur_r, cur_g, cur_b, previous.a);
img[imgIndex] = newCol;
Verbose($"QOI_OP_LUMA: {diff_green} {dr_dg} {db_dg}");
break;
Expand Down

0 comments on commit 2b9fcde

Please sign in to comment.