The ImageWin Module

This module contains support to create and display images under Windows 95/98, NT, and 2000.

The Dib Class

Dib (constructor)

Dib(mode, size). This constructor creates a Windows bitmap with the given mode and size. 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.

Methods

expose

expose(hdc). 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.

palette

palette(hdc). Installs the palette associated with the image in the given device context. The handle 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, and the image should be redrawn.

paste

paste(image, box). Pastes an image into the bitmap image. The box is 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. In any case, 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.