allow image widgets to do alpha-blitting

when the image (e.g. a PNG) does contain an alpha channel, that can
be honored by ImageWidget. It doesn't do so by default for compatibility
(arguably, we should change that in the future), it has to be enabled
by setting the "alpha" property to "true" (boolean, not string).
pull/1296/head
Hans-Werner Hilse 10 years ago
parent 0c7e01fd87
commit 0c80537003

@ -37,6 +37,8 @@ local ImageWidget = Widget:new{
height = nil,
-- if autoscale is true image will be rescaled according to screen dpi
autoscale = false,
-- when alpha is set to true, alpha values from the image will be honored
alpha = false,
_bb = nil
}
@ -108,7 +110,11 @@ function ImageWidget:paintTo(bb, x, y)
w = size.w,
h = size.h
}
bb:blitFrom(self._bb, x, y, 0, 0, size.w, size.h)
if self.alpha == true then
bb:alphablitFrom(self._bb, x, y, 0, 0, size.w, size.h)
else
bb:blitFrom(self._bb, x, y, 0, 0, size.w, size.h)
end
if self.invert then
bb:invertRect(x, y, size.w, size.h)
end

Loading…
Cancel
Save