bindex = blueShift/8;
}
- for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) {
- for(colptr = rowptr; colptr < &rowptr[w * 4]; colptr += 4) {
- *(dst++) = colptr[rindex];
- *(dst++) = colptr[gindex];
- *(dst++) = colptr[bindex];
+ int srcPad = pitch - w * 4;
+ while (h > 0) {
+ rdr::U8 *srcEndOfRow = (rdr::U8 *)src + w * 4;
+ while (src < srcEndOfRow) {
+ *(dst++) = src[rindex];
+ *(dst++) = src[gindex];
+ *(dst++) = src[bindex];
+ src += 4;
}
+ src += srcPad;
+ h--;
}
} else {
// Generic code
Pixel p;
rdr::U8 r, g, b;
+ int pixelSize = bpp/8;
- for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) {
- for(colptr = rowptr; colptr < &rowptr[w * bpp/8]; colptr += bpp/8) {
- p = pixelFromBuffer(colptr);
+ int srcPad = pitch - w * pixelSize;
+ while (h > 0) {
+ rdr::U8 *srcEndOfRow = (rdr::U8 *)src + w * pixelSize;
+ while (src < srcEndOfRow) {
+ p = pixelFromBuffer(src);
rgbFromPixel(p, cm, &r, &g, &b);
*(dst++) = r;
*(dst++) = g;
*(dst++) = b;
+ src += pixelSize;
}
+ src += srcPad;
+ h--;
}
}
}
if (needSameColor && (rdr::U32)colorValue != *colorPtr)
return false;
- for (dy = 0; dy < h; dy++) {
- for (dx = 0; dx < w; dx++) {
- if (colorValue != buf[dx])
+ int bufPad = stride - w;
+ while (h > 0) {
+ PIXEL_T *bufEndOfRow = buf + w;
+ while (buf < bufEndOfRow) {
+ if (colorValue != *(buf++))
return false;
}
- buf += stride;
+ buf += bufPad;
+ h--;
}
*colorPtr = (rdr::U32)colorValue;