|pythonware.com ::: library ::: Python Imaging Library Handbook (2003 Edition)|
The ImageWin module contains support to create and display images on Windows. It can be used with PythonWin as well as other user interface toolkits that provides access to Windows device contexts.
ImageWin.Dib(image) => Dib instance
ImageWin.Dib(mode, size) => Dib instance
This constructor creates a Windows bitmap from a PIL image, or from a given mode and size.
The mode can be one of "1", "L", 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. See the method descriptions below.
Expose (draw) the image using the given device context handle. The handle is an integer representing a Windows HDC handle.
In PythonWin, you can use the GetHandleAttrib method of the CDC class to get a suitable handle.
dib.draw(hdc, destination, source)
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.
Installs the palette associated with the image in the given device context. The handle argument is an integer representing a Windows HDC handle.
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 since the last updated, and the image should be redrawn.
Paste an image into the bitmap image. The bbox argument is a 4-tuple defining the left, upper, right, and lower pixel coordinate. If None is used instead of a tuple, the entire image is copied. In all cases, the size of the pasted image must match the size of the region. If the image mode does not match the bitmap mode, conversions are automatically applied.