Python Imaging Library: ImageWin Module(图像Windows模块)

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整数。所得到的对象可以传递给drawexpose方法。

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的QUERYNEWPALETTEPALETTECHANGED事件。

如果该方法返回一个非零值,那么在上一次更新后,一个或多个显示面板条目将被更改,并且应该重新绘制该图像。

paste

dib.paste(image, bbox)

将图像粘贴到位图图像中。

bbox参数是一个4元组,它定义了左、上、右和下像素坐标。

如果没有使用一个元组,那么整个图像将被复制。

在所有情况下,粘贴图像的大小必须与该区域的大小匹配。

如果图像模式与位图模式不匹配,则自动应用转换。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
RX Library 2.75 with Delphi 2009 support (by FlexGraphics software) ====================================================================== The Set of Native Delphi Components for Borland Delphi versions 1, 2, 3, 4, 5, 6, 7, 2005, 2006, 2009 and Borland C++ Builder 1, 3, 4, 5, 6, 2006 & 2009. 100% Source Code. Last revision date Oct 12, 1999. PLEASE FOLLOW THE INSTRUCTIONS PROVIDED IN THE INSTALLATION SECTION! TABLE OF CONTENTS ----------------- Latest Changes Overview History License Agreement Installation Demonstration Programs Source Files Using GIF Images Copyright Notes NEW FOR VERSION 2.75 -------------------- Delphi 5.0 & C++Builder 4.0 Compatibility New components: TRxLoginDialog New properties, events: TFormPlacement.RegistryRoot TFormPlacement.Version TFontComboBox.UseFonts TRxDBGrid.OnTopLeftChanged TRxDBLookupCombo.DisplayValues TStrHolder.Macros, TStrHolder.OnExpandMacros RxSpin.TValueType.vtHex New routines, methods, constants: SaveClipboardToStream, LoadClipboardFromStream (clipmon.pas) AppFileName, AppVerInfo (rxverinf.pas) XorString, XorEncode, XorDecode (strutils.pas) BUG FIXES. Overview -------- This version is the result of long unactivity of RX Library authors and some imperfections and bugs of other RX adaptations to Delphi 6. The authors of this version disclaim all warranties as to this software, whether express or implied, including without limitation any implied warranties of merchantability or fitness for a particular purpose. Use under your own responsibility, but comments (even critique) in English (or in Russian) are welcome. RX Library contains a large number of components, objects and routines for Borland Delphi with full source code. This library is compatible with Borland Delphi 1, 2, 3, 4, 5, 6 and Borland C++ Builder 1, 3, 4. This collection includes over 60 native Delphi components. RX Library is a freeware product. Feel free to distribute the library as long as all files are unmodified and kep

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值