[Interest] About copying the image buffer with alpha blending

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Aug 29 12:37:29 CEST 2012

Am 29.08.2012 um 12:05 schrieb Samuel Rødal <samuel.rodal at nokia.com>:

> On 08/29/2012 11:54 AM, ext song.7.liu at nokia.com wrote:
>> Is the premultiplied specified when creating QImage or other ?
> The QImage constructor takes the QImage::Format. But if you load the
> image from file it should already pick Format_ARGB32_Premultiplied by
> default if the image has an alpha channel.

As a matter of fact I am just in this very topic ("alpha-blending and premultiplied values") myself.

I am not entirely sure, but I think when I loaded a PNG with alpha channel the format was *not* premultiplied alpha (but "normal" RGBA32 instead).

It probably depends on the source file: if the original data is premultipied RGBA, then the resulting QImage is most likely also RGBA premultiplied.

(Does the PNG file format support "premultiplied" RGBA?)

In other words: "you get what you load"(tm) with QImage::load - which is good! Qt shouldn't convert data behind your back unnecessarily.

So in my case the PNG contained "normal" RGBA values - so that was the pixel format of the resulting QImage.

However: you can always query the pixel format after loading and explicitly request a (possibly costly) conversion, if necessary:



More information about the Interest mailing list