From 0c805370036518a0b3e382333d5ffd16d750ed09 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Fri, 28 Nov 2014 15:31:54 +0000 Subject: [PATCH 1/2] 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). --- frontend/ui/widget/imagewidget.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/imagewidget.lua b/frontend/ui/widget/imagewidget.lua index d28e7e380..ac6b84056 100644 --- a/frontend/ui/widget/imagewidget.lua +++ b/frontend/ui/widget/imagewidget.lua @@ -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 From b2e38ca80db8f984358588c2396fd97702bab469 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Fri, 28 Nov 2014 15:34:09 +0000 Subject: [PATCH 2/2] honor alpha when painting the dog-ear bookmark icon allows for different icons making use of that. For our current icon, it actually doesn't. Fixes #402 --- frontend/apps/reader/modules/readerdogear.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/apps/reader/modules/readerdogear.lua b/frontend/apps/reader/modules/readerdogear.lua index ee42ce0b5..a0bded8fc 100644 --- a/frontend/apps/reader/modules/readerdogear.lua +++ b/frontend/apps/reader/modules/readerdogear.lua @@ -13,6 +13,7 @@ local ReaderDogear = InputContainer:new{} function ReaderDogear:init() local widget = ImageWidget:new{ file = "resources/icons/dogear.png", + alpha = true, } self[1] = RightContainer:new{ dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},