# Module PIL.ImageWin

#### Module Summary:

    class Dib:
        def __init__(self, image, size=None)

> Create a Windows bitmap with the given mode and size.

    class HDC:
        def __init__(self)

> The ImageWin module contains support to create and display images under Windows 95/98, NT, 2000 and later.

## Classes

### The Dib Class

    Dib()

Create 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 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.

#### Constructor:

    Dib(image, size=None)

Create Windows bitmap.

#### Parameters:

`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.

#### Method Summary:

    expose(handle)

> Copy the bitmap contents to a device context.

    paste(im, box=None)

> Paste a PIL image into the bitmap image.

    query_palette(dc)

> Installs the palette associated with the image in the given device context.

### expose

    expose(handle)

Copy the bitmap contents to a device context.

#### Parameters:

`handle` -- Device context (HDC), cast to a Python integer, or a HDC or HWND instance. In PythonWin, you can use the GetHandleAttrib method of the CDC class to get a suitable handle.

### paste

    paste(im, box=None)

Paste a PIL image into the bitmap image.

#### Parameters:

`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_palette

    query_palette(dc)

Installs the palette associated with the image in the given device context.

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.

#### Parameters:

`dc` -- Device context (HDC), cast to a Python integer, or an HDC or HWND instance.

#### Returns:

A true value if one or more entries were changed (this indicates that the image should be redrawn).

### The HDC Class

    HDC()

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