On 10/10/2010 04:01, saulgo...@flashingtwelve.brickfilms.com wrote:
> Quoting Ofnuts<ofn...@laposte.net>:
>
>> Is there a practical, fast way, to detect this case, i.e, that the
>> selection covers the whole layer (or image?) and that no pixels remain
>> unselected? I assume that inverting the selection again and testing for
>> empty would work, but that would be two selection inversions in the
>> normal case and that may be a bit costly.
> The following appears to be about twice as fast as the two inversion approach.
>
> (let ((count (cdddr (gimp-histogram (car (gimp-image-get-selection image))
>                                       HISTOGRAM-VALUE
>                                       255
>                                       255))))
>     (= (car count) (cadr count)) ; compare num of all pixels to all white 
> pixels
>     )

Exactly what the doctor ordered. Thanks (and to Rob...). However, the 
only documentation I found of this function was in the API browser of 
the python-fu console. I couldn't find it in the files I sampled at 
<http://developer.gimp.org/api/2.0/index.html>. Where is it documented?

-- 
Bertrand


_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to