Skip to content

Commit

Permalink
Fix fill and invert pixel methods for BufferRgb8888
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Aug 9, 2022
1 parent 5e0378c commit 618e2e1
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override void Fill(int x, int y, int width, int height, Color color)
}

byte[] value = { color.R, color.G, color.B, color.A };
int index = y * Width * 4 + x * 4 - 1;
int index = (y * Width + x) * 4 - 1;

//fill the first line
for (int i = 0; i < width; i++)
Expand All @@ -95,7 +95,7 @@ public override void Fill(int x, int y, int width, int height, Color color)
(y + j) * Width * 4 + x * 4,
Buffer,
(y + j + 1) * Width * 4 + x * 4,
width);
width * 4);
}
}

Expand All @@ -106,7 +106,14 @@ public override void Fill(int x, int y, int width, int height, Color color)
/// <param name="y">y position of pixel</param>
public override void InvertPixel(int x, int y)
{
throw new NotImplementedException();
var color = GetPixel(x, y);

//split into R,G,B & invert
byte r = (byte)~color.R;
byte g = (byte)~color.G;
byte b = (byte)~color.B;

SetPixel(x, y, new Color(r, g, b, color.A));
}

/// <summary>
Expand Down

0 comments on commit 618e2e1

Please sign in to comment.