[Interest] QImage detect full transparent

maitai maitai at virtual-winds.org
Sun Feb 25 23:32:51 CET 2018


Wow! Nice idea. Probably a bit faster than to compare with a known fully
transparent image.

Le 25-02-2018 21:41, Xavier Bigand a écrit :

> I think that I forgot to tell that it can be faster to do a pseudo random search than a pure straight forward brut-force lookup in the alpha channel buffer. 
> Depending on type of pictures you will analyse, it might be faster to have an algorithm that do something like the quick search algorithm. 
> For exemple just consider the alpha channel as one dimensional array, and put a pivot point at the half of the array, each pivot point should be tested and considered as a end and start of 2 new chunks of array. Then continue to add pivot points at the half of chunks,... 
> You may also consider to multi-thread a such algorithm with a map reduce, take a look to https://doc.qt.io/qt-5.10/qtconcurrent-index.html. 
> 
> 2018-02-25 21:27 GMT+01:00 Xavier Bigand <flamaros.xavier at gmail.com>:
> 
> A complete scan will always be relatively slow, if you can you should consider to do a cache or something similar. 
> Depending of your constraints the cache should be created while packaging/building your application or when the user will request the info the first time. 
> 
> The cacheKey() won't work in my opinion because their should be have no guaranty that rgb components are at 0 too if the alpha channel is at 0, so their is many different images (with different keys) that can be fully transparent. 
> 
> 2018-02-25 20:23 GMT+01:00 maitai <maitai at virtual-winds.org>:
> 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?
> 
> Thanks
> Philippe.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest [1] 
> 
> -- 
> 
> Xavier

  -- 

Xavier 

Links:
------
[1] http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180225/ca27f6a7/attachment.html>


More information about the Interest mailing list