Browse Source

Optimize getImageData()

Mostly for fully transparent pixels
v1.x
Alexander Parshin 10 years ago
parent
commit
6de09834cf
  1. 14
      src/PixelArray.cc

14
src/PixelArray.cc

@ -114,10 +114,16 @@ PixelArray::PixelArray(Canvas *canvas, int sx, int sy, int width, int height):
uint8_t g = *pixel >> 8;
uint8_t b = *pixel;
dst[bx + 3] = a;
float alpha = (float) a / 255;
dst[bx + 0] = (int)((float) r / alpha);
dst[bx + 1] = (int)((float) g / alpha);
dst[bx + 2] = (int)((float) b / alpha);
if (a != 0 && a != 255) {
float alpha = (float) a / 255;
dst[bx + 0] = (int)((float) r / alpha);
dst[bx + 1] = (int)((float) g / alpha);
dst[bx + 2] = (int)((float) b / alpha);
} else {
dst[bx + 0] = r;
dst[bx + 1] = g;
dst[bx + 2] = b;
}
}
dst += dstStride;
}

Loading…
Cancel
Save