The alpha RLE code in Gimp makes per-pixel alpha much faster than before,
and actually not very much slower than normal simple transparency.
In fact, there is almost no difference in performance between blitting
a colourkeyed image, and the same image but with an alpha channel (and
thus only 0 and 255 as alpha values), if both are RLE encoded.
This makes it useful for a number of variants, especially sprites and
text with “soft” (antialiased) edges. Here the translucent (neither
opaque nor completely transparent) pixels are only present in a thin
stripe around the edges, and thus not too costly to blit.
I’ve noticed that it can be hard to find stray translucent pixels in an
image — almost-transparent pixels that are hiding in the clear areas,
or almost-opaque pixels in the filled areas — especially after you have
being playing with it long enough. Even if these rogue pixels don’t make
a visible difference, they will slow things down. So I made a small
gimp script, and thought I should share it.
Save it somewhere (.gimp-1.1/scripts/showtrans.scm, for example), and
(re)start Gimp. Now try the right-click menu in
Script-Fu->Utils->Show Translucency. It creates a layer that colours
opaque pixels red, transparent ones black, and the rest green.
The intrepid pixel hunter can then eliminate nasty greenies by painting
them black or red, and then use select by colour and clear (or anti-erase)
in the original layer to get rid of them. Happy Gimping!
;;; Create a new layer partitioning pixels by alpha: 0, 1…254, 255
;;;
;;; This is useful to locate stray translucent pixels when editing images
;;; with an alpha channel
(define showtrans-opaque-color '(255 0 0))
(define showtrans-translucent-color '(0 255 0))
(define showtrans-transparent-color '(0 0 0))
(define (fill-selection image drawable color)
(if (= (car (gimp-selection-is-empty image)) 0)
(let ((old-fg (car (gimp-palette-get-foreground))))
(gimp-palette-set-foreground color)
(gimp-bucket-fill drawable 0 0 100 0 0 0 0)
(gimp-palette-set-foreground old-fg))))
(define (script-fu-show-trans image drawable)
(if (gimp-drawable-is-layer drawable)
(begin
(gimp-image-undo-disable image)
(let ((lay1 (car (gimp-layer-copy drawable 1)))
(lay2 (car (gimp-layer-copy drawable 1))))
(gimp-image-add-layer image lay1 -1)
(gimp-image-add-layer image lay2 -1)
(gimp-selection-none image)
(plug-in-threshold-alpha 1 image lay1 0)
(gimp-selection-layer-alpha lay1)
(fill-selection image lay1 showtrans-translucent-color)
(gimp-selection-invert image)
(fill-selection image lay1 showtrans-transparent-color)
(gimp-selection-none image)
(plug-in-threshold-alpha 1 image lay2 254)
(gimp-selection-layer-alpha lay2)
(gimp-image-remove-layer image lay2)
(fill-selection image lay1 showtrans-opaque-color)
(gimp-selection-none image)
(gimp-layer-set-name lay1 “Translucency Map”))
(gimp-image-undo-enable image))))
(script-fu-register
"script-fu-show-trans"
"/Script-Fu/Utils/Show Translucency"
“Show map of translucent/opaque pixels”
“Mattias Engdeg?rd <@Mattias_Engdegard>”
“Mattias Engdeg?rd”
"July 2000"
"RGBA"
SF-IMAGE “Input Image” 0
SF-DRAWABLE “Input Drawable” 0)