Skip to content

Commit 48d05cf

Browse files
Added alpha support to the Off Screen HTML renderer
1 parent fe316b2 commit 48d05cf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

OffScreenHTML.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
"""
44
test of rendering HTML to an off-screen bitmap
5+
6+
This version uses a wx.GCDC, so you can have an alpha background.
7+
8+
Works on OS-X, may need an explicite alpha bitmap on other platforms
59
"""
610

711
import wx
@@ -17,7 +21,8 @@ def __init__(self, width, height):
1721
self.HR = wx.html.HtmlDCRenderer()
1822

1923
# a bunch of defaults...
20-
self.BackgroundColor = "White"
24+
self.BackgroundColor = "white"
25+
self.BackgroundColor = (255, 255, 255, 50)
2126
self.Padding = 10
2227

2328

@@ -27,6 +32,7 @@ def Render(self, source):
2732
"""
2833
DC = wx.MemoryDC()
2934
DC.SelectObject(self.Buffer)
35+
DC = wx.GCDC(DC)
3036
DC.SetBackground(wx.Brush(self.BackgroundColor))
3137
DC.Clear()
3238

@@ -78,7 +84,8 @@ def Convert(self, text):
7884
that will show if it can take care of the basic rendering for us, and
7985
auto-wrap, and all sorts of nifty stuff like that
8086
</p>
81-
87+
<p>
88+
and here is some <b> Bold Text </b>
8289
<p> It does seem to work OK </p>
8390
"""
8491

0 commit comments

Comments
 (0)