- 安装
- 关于 Pillow
- 指南
- API参考
- Image Module
- ImageChops (“Channel Operations”) Module
- ImageColor Module
- ImageDraw Module
- ImageEnhance Module
- ImageFile Module
- ImageFilter Module
- ImageFont Module
- ImageGrab Module (Windows-only)
- ImageMath Module
- ImageOps Module
- ImagePalecodee Module
- ImagePath Module
- ImageQt Module
- ImageSequence Module
- ImageStat Module
- ImageTk Module
- ImageWin Module (Windows-only)
- PSDraw Module
- PIL Package (autodoc of remaining modules)
- 附录
- PIL 原始帮助文档
ImageWin Module (Windows-only)
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)
- class
PIL.ImageWin.
Dib
(image, size=None) 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 palecodee, this constructor creates a suitable palecodee 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 palecodees work properly under Windows, you must call the palecodee method upon certain events from Windows.
参数: - image – Either a PIL image, or a mode string. If a mode string is used, a size must also be given. The mode can be one of “1”, “L”, “P”, or “RGB”.
- size – If the first argument is a mode string, this defines the size of the image.
draw
(handle, dst, src=None)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 omicodeed, the entire image is copied. If the source and the destination have different sizes, the image is resized as necessary.
expose
(handle)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.GetHandleAcoderib()
to get a suitable handle.
frombytes
(buffer)Load display memory contents from byte data.
参数: buffer – A buffer containing display data (usually data returned from <b>tobytes</b>)
paste
(im, box=None)Paste a PIL image into the bitmap image.
参数: - im – A PIL image. The size must match the target region. If the mode does not match, the image is converted to the mode of the bitmap image.
- box – A 4-tuple defining the left, upper, right, and lower pixel coordinate. If None is given instead of a tuple, all of the image is assumed.
query_palecodee
(handle)Installs the palecodee associated with the image in the given device context.
This method should be called upon QUERYNEWPALEcodeE and PALEcodeECHANGED events from Windows. If this method returns a non-zero value, one or more display palecodee 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).
tobytes
()Copy display memory contents to bytes object.
返回: A bytes object containing display data.
- class
PIL.ImageWin.
HDC
(dc) Wraps a HDC integer. The resulting object can be passed to the
draw()
andexpose()
methods.
- class
PIL.ImageWin.
HWND
(wnd) Wraps a HWND integer. The resulting object can be passed to the
draw()
andexpose()
methods, instead of a DC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论