nbsp; // sample
// now loop from srcX to srcX2 and add up the values for
// each channel
do
{
argb = srcPixels[srcX + y * srcW];
a += ((argb & 0xff000000) >> 24); // alpha channel
r += ((argb & 0x00ff0000) >> 16); // red channel
g += ((argb & 0x0000ff00) >> 8); // green channel
b += (argb & 0x000000ff); // blue channel
++count; // count the pixel
++srcX; // move on to the next pixel
} while (srcX <= srcX2
&& srcX + y * srcW < srcPixels.length);
// average out the channel values
a /= count;
r /= count;
g /= count;
b /= count;
// recreate color from the averaged channels and place it
// into the temporary buffer
tmpPixels[destX + y * destW] = ((a << 24) | (r << 16)
| (g << 8) | b);
}
}