发布于 2015-09-11 16:08:31 | 191 次阅读 | 评论: 0 | 来源: 网络整理
The ImageWin module contains support to create and display images on Windows.
ImageWin can be used with PythonWin and other user interface toolkits that provide access to Windows device contexts or window handles. For example, Tkinter makes the window handle available via the winfo_id method:
from PIL import ImageWin
dib = ImageWin.Dib(...)
hwnd = ImageWin.HWND(widget.winfo_id())
dib.draw(hwnd, xy)
A Windows bitmap with the given mode and size. The mode can be one of “1”, “L”, “P”, or “RGB”.
If the display requires a palette, this constructor creates a suitable palette and associates it with the image. For an “L” image, 128 greylevels are allocated. For an “RGB” image, a 6x6x6 colour cube is used, together with 20 greylevels.
To make sure that palettes work properly under Windows, you must call the palette method upon certain events from Windows.
参数: |
|
---|
Same as expose, but allows you to specify where to draw the image, and what part of it to draw.
The destination and source areas are given as 4-tuple rectangles. If the source is omitted, the entire image is copied. If the source and the destination have different sizes, the image is resized as necessary.
Copy the bitmap contents to a device context.
参数: | handle – Device context (HDC), cast to a Python integer, or a HDC or HWND instance. In PythonWin, you can use the CDC.GetHandleAttrib() to get a suitable handle. |
---|
Load display memory contents from byte data.
参数: | buffer – A buffer containing display data (usually data returned from <b>tobytes</b>) |
---|
Paste a PIL image into the bitmap image.
参数: |
|
---|
Installs the palette associated with the image in the given device context.
This method should be called upon QUERYNEWPALETTE and PALETTECHANGED events from Windows. If this method returns a non-zero value, one or more display palette entries were changed, and the image should be redrawn.
参数: | handle – Device context (HDC), cast to a Python integer, or an HDC or HWND instance. |
---|---|
返回: | A true value if one or more entries were changed (this indicates that the image should be redrawn). |