]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/Image.py
6 #----------------------------------------------------------------------
8 def runTest(frame
, nb
, log
):
9 bmp
= wx
.Image(opj('bitmaps/image.bmp'), wx
.BITMAP_TYPE_BMP
).ConvertToBitmap()
10 gif
= wx
.Image(opj('bitmaps/image.gif'), wx
.BITMAP_TYPE_GIF
).ConvertToBitmap()
11 png
= wx
.Image(opj('bitmaps/image.png'), wx
.BITMAP_TYPE_PNG
).ConvertToBitmap()
12 jpg
= wx
.Image(opj('bitmaps/image.jpg'), wx
.BITMAP_TYPE_JPEG
).ConvertToBitmap()
14 panel
= wx
.Panel(nb
, -1)
17 wx
.StaticBitmap(panel
, -1, bmp
, (10, pos
), (bmp
.GetWidth(), bmp
.GetHeight()))
19 pos
= pos
+ bmp
.GetHeight() + 10
20 wx
.StaticBitmap(panel
, -1, gif
, (10, pos
), (gif
.GetWidth(), gif
.GetHeight()))
22 pos
= pos
+ gif
.GetHeight() + 10
23 wx
.StaticBitmap(panel
, -1, png
, (10, pos
), (png
.GetWidth(), png
.GetHeight()))
25 pos
= pos
+ png
.GetHeight() + 10
26 wx
.StaticBitmap(panel
, -1, jpg
, (10, pos
), (jpg
.GetWidth(), jpg
.GetHeight()))
30 #----------------------------------------------------------------------
37 This class encapsulates a platform-independent image. An image can be created
38 from data, or using <code>wxBitmap.ConvertToImage</code>. An image can be loaded from
39 a file in a variety of formats, and is extensible to new formats via image
40 format handlers. Functions are available to set and get image bits, so it can
41 be used for basic image manipulation.
43 <p>The following image handlers are available. wxBMPHandler is always installed
44 by default. To use other image formats, install the appropriate handler or use
45 <code>wx.InitAllImageHandlers()</code>.
49 <tr><td width=25%>wxBMPHandler</td> <td>For loading and saving, always installed.</td></tr>
50 <tr><td>wxPNGHandler</td> <td>For loading and saving.</td> </tr>
51 <tr><td>wxJPEGHandler</td> <td>For loading and saving.</td> </tr>
52 <tr><td>wxGIFHandler</td> <td>Only for loading, due to legal issues.</td> </tr>
53 <tr><td>wxPCXHandler</td> <td>For loading and saving.</td> </tr>
54 <tr><td>wxPNMHandler</td> <td>For loading and saving.</td> </tr>
55 <tr><td>wxTIFFHandler</td> <td>For loading and saving.</td> </tr>
56 <tr><td>wxIFFHandler</td> <td>For loading only.</td> </tr>
57 <tr><td>wxXPMHandler</td> <td>For loading and saving.</td> </tr>
58 <tr><td>wxICOHandler</td> <td>For loading and saving.</td> </tr>
59 <tr><td>wxCURHandler</td> <td>For loading and saving.</td> </tr>
60 <tr><td>wxANIHandler</td> <td>For loading only.</td> </tr>
63 <p>When saving in PCX format, wxPCXHandler will count the number of different
64 colours in the image; if there are 256 or less colours, it will save as 8 bit,
65 else it will save as 24 bit.
67 <p>Loading PNMs only works for ASCII or raw RGB images. When saving in PNM format,
68 wxPNMHandler will always save as raw RGB.
73 if __name__
== '__main__':
76 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])