Merge pull request #1296 from hwhw/imagewidget_alpha

Imagewidget alpha
pull/1297/head
Huang Xin 10 years ago
commit 1b07698952

@ -13,6 +13,7 @@ local ReaderDogear = InputContainer:new{}
function ReaderDogear:init() function ReaderDogear:init()
local widget = ImageWidget:new{ local widget = ImageWidget:new{
file = "resources/icons/dogear.png", file = "resources/icons/dogear.png",
alpha = true,
} }
self[1] = RightContainer:new{ self[1] = RightContainer:new{
dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h}, dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},

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

Loading…
Cancel
Save