You can increase the speed of both SetPixel
and GetPixel
by doing the following:
- Add the line 'int step = 0' at the LockBitmap class level.
- Remove 'int' declation of 'step' in the LockBits method and calculate as is.
- In both SetPixel and GetPixel, remove the line:
int cCount = Depth / 8;
- In both
SetPixel
and GetPixel
, replace cCount
with Step
:
int i = ((y * Width) + x) * cCount;
now becomes:
int i = ((y * Width) + x) * Step;