I see this code in setPixel() from qimage.cpp:
case Format_ARGB32:
case Format_ARGB32_Premultiplied:
((uint *)s)[x] = index_or_rgb;
break;
case Format_ARGB32:
case Format_ARGB32_Premultiplied:
((uint *)s)[x] = index_or_rgb;
break;
To copy to clipboard, switch view to plain text mode
This means, that the RGB values are not premultiplied with alpha, when the pixel is set. To set the pixel values correctly, do I need to do this?
image.setPixel(x, y, qRgba(qt_div_255(color.alpha() * color.red()),
qt_div_255(color.alpha() * color.green()),
qt_div_255(color.alpha() * color.blue()),
color.alpha()));
image.setPixel(x, y, qRgba(qt_div_255(color.alpha() * color.red()),
qt_div_255(color.alpha() * color.green()),
qt_div_255(color.alpha() * color.blue()),
color.alpha()));
To copy to clipboard, switch view to plain text mode
Or when and how do the RGB values get premultiplied? In other words, how to set the pixel so it contains the correct value?
Bookmarks