From 8a88769e50fcf3c538498f6fecdd2d0c7abca6ec Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 10 Mar 2004 06:52:36 +0000 Subject: [PATCH] Add demo showing drawing of an image with an Alpha channel. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/demo/DragImage.py | 1 + wxPython/demo/ImageAlpha.py | 66 +++++++++++++++++++++++++++++++ wxPython/demo/Main.py | 2 + wxPython/demo/bitmaps/toucan.png | Bin 0 -> 12901 bytes 4 files changed, 69 insertions(+) create mode 100644 wxPython/demo/ImageAlpha.py create mode 100644 wxPython/demo/bitmaps/toucan.png diff --git a/wxPython/demo/DragImage.py b/wxPython/demo/DragImage.py index f686421b63..7107fc3244 100644 --- a/wxPython/demo/DragImage.py +++ b/wxPython/demo/DragImage.py @@ -51,6 +51,7 @@ class DragCanvas(wx.ScrolledWindow): # Make a shape from an image and mask. This one will demo # dragging outside the window bmp = images.getTestStarBitmap() + ##bmp = wx.Bitmap('bitmaps/toucan.png') shape = DragShape(bmp) shape.pos = (5, 5) shape.fullscreen = True diff --git a/wxPython/demo/ImageAlpha.py b/wxPython/demo/ImageAlpha.py new file mode 100644 index 0000000000..cec268ce6e --- /dev/null +++ b/wxPython/demo/ImageAlpha.py @@ -0,0 +1,66 @@ + +import wx # This module uses the new wx namespace +from Main import opj + + +#---------------------------------------------------------------------- + +msg = "This is some text that will appear behind the image..." + +class TestPanel(wx.Panel): + def __init__(self, parent, log): + self.log = log + wx.Panel.__init__(self, parent, -1) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + + + def OnPaint(self, evt): + dc = wx.PaintDC(self) + dc.SetBackground(wx.Brush("WHITE")) + dc.Clear() + + dc.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD, True)) + dc.DrawText("Bitmap alpha blending (on wxMSW and wxGTK)", + (25,25)) + + bmp = wx.Bitmap(opj('bitmaps/toucan.png')) + dc.DrawBitmap(bmp, (25,100), True) + + dc.SetFont(self.GetFont()) + y = 75 + for line in range(10): + y += dc.GetCharHeight() + 5 + dc.DrawText(msg, (200, y)) + dc.DrawBitmap(bmp, (250,100), True) + + + +#---------------------------------------------------------------------- + +def runTest(frame, nb, log): + win = TestPanel(nb, log) + return win + +#---------------------------------------------------------------------- + + + +overview = """ +

Images with Alpha

+ +wxMSW and wxGTK now support alpha channels of supported image +types, and will properly blend that chennel when drawing a +bitmap. It is not supported yet on wxGTK, (if you would like to +change that please submit a patch!) + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) + diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index 9d2d87fd77..6a2146104b 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -38,6 +38,7 @@ _treeList = [ 'GridBagSizer', 'Cursor', 'PyPlot', + 'ImageAlpha', ]), # managed windows == things with a (optional) caption you can close @@ -193,6 +194,7 @@ _treeList = [ 'Cursor', 'DragImage', 'Image', + 'ImageAlpha', 'ImageFromStream', 'Mask', 'Throbber', diff --git a/wxPython/demo/bitmaps/toucan.png b/wxPython/demo/bitmaps/toucan.png new file mode 100644 index 0000000000000000000000000000000000000000..03960d4939938541ca3f8efee4bf13ffdecbb2f5 GIT binary patch literal 12901 zcma*NWpo@(vMt(@TFlH07Be$5GlRv<%*<@D#mr!V#mp>=(Xz$NEcMklbI#m(>%AXu zud1#cJ2EmWGkdMBijHVyMJYr$JU9RVfG8s^uKIZ``aIKNAOHX`!oF1CrvbDSQ4j%u zMHH|cr5gbN5CCO)b%{^?{|#6GI1B*%zje6(GU5NlRXmX=`N0_(A%xV>KIS3t$)QLv zQPAKaY!jf6!6DFKA+BP;aS(tXOVE|;Uwp<0CBPxek%2QX+9N}6AR78ggv z7y<(tDDvfVZh(LUCaDtRFhN+r_B0_*rDFZ%cgL7s9GZxYKaNytiAy8o< zK4ankJ;1+)_%uHc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