[Interest] QImage detect full transparent
Allan Sandfeld Jensen
kde at carewolf.com
Sun Feb 25 20:55:39 CET 2018
On Sonntag, 25. Februar 2018 20:23:32 CET maitai wrote:
> Hello,
> Seems quite basic, but I need a **fast** way to know if a QImage is just
> full transparent. I know the size in advance (256x256). If it were a
> QPixmap I would use cacheKey() and compare with the cacheKey of a full
> transparent image. For a QImage I can compare it with a preset
> transparent image, or extract the alpha channel, or etc of course. But I
> need a really fast way.
>
> Any idea?
>
There is a private API for that which QPixmap uses
QImageData::checkForAlphaPixels() can be accessed via QImage::d_ptr()-
>checkForAlphaPixels().
Of course being private API there is not guarantee it will keep working, and
if you use it you might not be able to link with newer Qt versions.
You can ofcourse also just look at the code in qimage.cpp and do something
similar.
`Allan
More information about the Interest
mailing list