Python Imaging Library: ImageWin Module(图像Windows模块)
来源:互联网 发布:gm预测软件2008 编辑:程序博客网 时间:2024/06/03 04:58
Python Imaging Library: ImageWin Module(图像Windows模块)
ImageWin模块支持在Windows上创建和显示图像。
ImageWin可以与PythonWin或其他用户界面工具包一起使用,这些工具包可以提供对Windows设备上下文或窗口句柄的访问。
例如,Tkinter让窗口可以通过winfo_id方法获得:
dib = ImageWin.Dib(...)hwnd = ImageWin.HWND(widget.winfo_id())
dib.draw(hwnd, xy)
Dib类
Dib
ImageWin.Dib(image) ⇒ Dib instance
ImageWin.Dib(mode, size) ⇒ Dib instance
这个构造函数从一个PIL图像中创建一个Windows位图,或者根据给定模式和大小创建一个Windows位图。
图像模式可以是“1”、“L”或“RGB”。
如果显示需要一个调色板,这个构造函数会创建一个合适的调色板,并将其与图像关联起来。
对于一个“L”图像,将分配128个灰色级别。对于一个“RGB”图像,使用一个6x6x6的彩色立方体,共计20个灰色级别。
为了确保调色板在Windows下正常工作,您必须在Windows的某些事件上调用调色板方法。请参阅下面的方法描述。
Helper类
HDC
HDC(dc)
包装(Wraps)一个HDC整数。所得到的对象可以传递给draw和expose方法。
HWND
HWND(dc)
包装(Wraps)一个HWND整数。所得到的对象可以传递给draw和expose方法,而不是DC。
方法
expose
dib.expose(hdc)
使用给定的设备上下文句柄曝光(绘制)图像。
句柄是一个表示Windows HDC句柄或HDC或HWND对象的整数。
在PythonWin中,您可以使用CDC类的GetHandleAttrib方法获得一个合适的句柄。
draw
dib.draw(hdc, destination)
dib.draw(hdc, destination, source)
与曝光(绘制)图像(expose)相同,但是允许您指定在哪里绘制图像,以及绘制它的哪一部分。
目标区域和源区域使用4元组矩形指定。如果省略了源区域,那么整个图像就会被复制。
如果源区域和目标区域大小不同,则图像根据需要调整大小。
palette
dib.palette(handle)
在给定的设备上下文中安装与图像相关联的调色板。
句柄参数是一个表示Windows HDC句柄的整数。
应该调用这个方法来响应来自Windows的QUERYNEWPALETTE和PALETTECHANGED事件。
如果该方法返回一个非零值,那么在上一次更新后,一个或多个显示面板条目将被更改,并且应该重新绘制该图像。
paste
dib.paste(image, bbox)
将图像粘贴到位图图像中。
bbox参数是一个4元组,它定义了左、上、右和下像素坐标。
如果没有使用一个元组,那么整个图像将被复制。
在所有情况下,粘贴图像的大小必须与该区域的大小匹配。
如果图像模式与位图模式不匹配,则自动应用转换。
- Python Imaging Library: ImageWin Module(图像Windows模块)
- Python Imaging Library: ImageColor Module(图像颜色模块)
- Python Imaging Library: ImageChops Module(图像通道操作模块)
- Python Imaging Library:ImageDraw Module(图像绘制模块)
- Python Imaging Library: ImageEnhance Module(图像增强模块)
- Python Imaging Library: ImageFilter Module(图像滤波模块)
- Python Imaging Library: ImageGrab Module(图像采集模块)
- Python Imaging Library: ImageMath Module(图像数学运算模块)
- Python Imaging Library: ImageOps Module(图像运算模块)
- Python Imaging Library: ImagePalette Module(图像调色板模块)
- Python Imaging Library: ImagePath Module(图像路径模块)
- Python Imaging Library: ImageQt Module(图像QT模块)
- Python Imaging Library: ImageSequence Module(图像序列模块)
- Python Imaging Library: ImageStat Module(图像统计模块)
- Python Imaging Library: ImageTk Module(图像Tkinter模块)
- Python Imaging Library: ImageFile Module(图像文件模块)
- Python Imaging Library: PSDraw Module(Postscript打印机模块)
- 安装 Python Imaging Library(PIL)
- 171031 Matlab数字图像处理-01-绪言
- 用人工智能和深度学习给游戏带来生命
- 奇异值理解
- LINQ Lambda表达式
- 那些坑爹的老代码,究竟改还是不改?!
- Python Imaging Library: ImageWin Module(图像Windows模块)
- EasyUI入门8 EasyUI在IE浏览器中渲染速度非常慢的解决办法
- python的格式化输出format
- Java 集合深入理解(7):ArrayList
- jmeter中Parameters和Body Data区别
- runtime简单介绍
- [几何]判断点是否在不规则多边形内
- Spring Cloud Zuul中路由配置细节
- ViewPager无限轮播,简单实现