void ProcessPixels(byte[] curr, int xOffset, int step, int y, int width)
{
int srcX, dstX;
int[] outp = GetPixel(curr);
int sizes = 0;
switch (colorType) {
case 0:
case 3:
case 4:
sizes = 1;
break;
case 2:
case 6:
sizes = 3;
break;
}
if (image != null) {
dstX = xOffset;
int yStride = (sizes*this.width*(bitDepth == 16 ? 8 : bitDepth)+ 7)/8;
for (srcX = 0; srcX < width; srcX++) {
SetPixel(image, outp, inputBands * srcX, sizes, dstX, y, bitDepth, yStride);
dstX += step;
}
}
if (palShades) {
if ((colorType & 4) != 0) {
if (bitDepth == 16) {
for (int k = 0; k < width; ++k) {
int t = k * inputBands + sizes;
outp[t] = Util.USR(outp[t], 8);
}
}
int yStride = this.width;
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
SetPixel(smask, outp, inputBands * srcX + sizes, 1, dstX, y, 8, yStride);
dstX += step;
}
}
else { //colorType 3
int yStride = this.width;
int[] v = new int[1];
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
int idx = outp[srcX];
if (idx < trans.Length)
v[0] = trans[idx];
else
v[0] = 255; // Patrick Valsecchi
SetPixel(smask, v, 0, 1, dstX, y, 8, yStride);
dstX += step;
}
}
}
else if (genBWMask) {
switch (colorType) {
case 3: {
int yStride = (this.width + 7) / 8;
int[] v = new int[1];
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
int idx = outp[srcX];
v[0] = ((idx < trans.Length && trans[idx] == 0) ? 1 : 0);
SetPixel(smask, v, 0, 1, dstX, y, 1, yStride);
dstX += step;
}
break;
}
case 0: {
int yStride = (this.width + 7) / 8;
int[] v = new int[1];
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
int g = outp[srcX];
v[0] = (g == transRedGray ? 1 : 0);
SetPixel(smask, v, 0, 1, dstX, y, 1, yStride);
dstX += step;
}
break;
}
case 2: {
int yStride = (this.width + 7) / 8;
int[] v = new int[1];
dstX = xOffset;
for (srcX = 0; srcX < width; srcX++) {
int markRed = inputBands * srcX;
v[0] = (outp[markRed] == transRedGray && outp[markRed + 1] == transGreen
&& outp[markRed + 2] == transBlue ? 1 : 0);
SetPixel(smask, v, 0, 1, dstX, y, 1, yStride);
dstX += step;
}
break;
}
}
}
}