- data[(x << 2) + 0] = *ptr++;
- data[(x << 2) + 1] = *ptr++;
- data[(x << 2) + 2] = *ptr++;
- if ( image->HasAlpha() )
- {
- data[(x << 2) + 3] = image->GetAlpha(x, y);
- }
- else if (( !image->HasMask() ) || \
- (data[(x << 2) + 0] != image->GetMaskRed()) || \
- (data[(x << 2) + 1] != image->GetMaskGreen()) || \
- (data[(x << 2) + 2] != image->GetMaskBlue()))
- {
- data[(x << 2) + 3] = 255;
- }
- else
+ register const int index = x * bytesPerPixel;
+ data[index + 0] = *ptr++;
+ data[index + 1] = *ptr++;
+ data[index + 2] = *ptr++;
+
+ if (usesAlpha)