Next: , Previous: , Up: Device Independent Bitmap Utilities   [Contents][Index]


18.3.1 DIB procedures

The following procedures have typed parameters, using the same convention as windows-procedure.

procedure: open-dib (filename string)

Return type: dib. Calls the OpenDIB entry of DIBUTILS.DLL. If the return value is not #f then the file filename was found, successfully opened, and the contents were suitable for loading into memory as a device independent bitmap.

procedure: write-dib (filename string) (dib dib)

Return type: bool. Calls the WriteDIB entry of DIBUTILS.DLL. Returns #t if the file filename could be opened and written to. After this operation the file contains the bitmap data in a standard format that is understood by open-dib and various system utilities like the bitmap editor. Any problems resulting in failure are signalled by a #f return value.

procedure: bitmap-from-dib (dib dib) (palette hpalette)

Return type: hbitmap. Calls the BitmapFromDib entry of DIBUTILS.DLL. The returned value is a device dependent bitmap. The colours from the DIB are matched against colors in palette.

procedure: dib-from-bitmap (bitmap hbitmap) (style dword) (bits word) (palette hpalette)

Return type: dib. Returns a DIB containing the same image as the device dependent bitmap bitmap. Style determines the kind of DIB, e.g. compression style. Calls the DibFromBitmap entry of DIBUTILS.DLL.

procedure: dib-blt (dest hdc) (x int) (y int) (w int) (h int) (src dib) (src-x int) (src-y int) (raster-op long)

Return type: bool. Calls the DibBlt entry of DIBUTILS.DLL. Similar to the Win32 API BitBlt call, but draws a DIB rather than a piece of another device context. Draws the dib on device context hdc at position (x,y). A rectangle of width w and height h is copied from position (src-x,src-y) of dib. Raster-op is supposed to allow the source and destination to be combined but I don’t think I got this right so stick to SRCCOPY.

procedure: delete-dib (dib dib)

Return type: bool. This procedure reclaims the storage occupied by a DIB. After being deleted, the DIB should not be used. This procedure allows the programmer to reclaim external heap storage rather than risking it running out before the next garbage collection.

procedure: dib-height (dib dib)

Return type: int. Calls the DibHeight expand entry of DIBUTILS.DLL, which returns the height of the bitmap in pixels.

procedure: dib-width (dib dib)

Return type: int. Calls the DibWidth entry of DIBUTILS.DLL, which returns the width of the bitmap in pixels.

procedure: copy-bitmap (bm hbitmap)

Return type: hbitmap. Calls the CopyBitmap of DIBUTILS.DLL, which creates a new bitmap with the same size and contents as the original.

procedure: create-dib (width int) (height int) (style int) (depth int) (palette hpalette)

Return type: dib. Calls the CreateDIB entry of DIBUTILS.DLL. Creates a DIB of width by height pixels and depth bits of colour information. The style parameter determines how the bitmap is stored. I have only ever used BI_RGB. If depth<=8 then the palette determines the DIB’s colour table.

procedure: crop-bitmap (bm hbitmap) (left int) (top int) (right int) (bottom int)

Return type: hbitmap. Calls the CropBitmap entry of DIBUTILS.DLL. Returns a new bitmap containing the image from a region of the original.

procedure: dib-set-pixels-unaligned dib (pixels string)

Return type: bool. Calls the DIBSetPixelsUnaligned entry of
DIBUTILS.DLL. Stuffs bytes from pixels into the bitmap. There are no alignment constraints on pixels (the usual way of doing this is to use the SetDIBits function which requires that every scan line of the bitmap is 32-bit word aligned, even if the scan lines are not a multiple of 4 bytes long). doing this


Next: , Previous: , Up: Device Independent Bitmap Utilities   [Contents][Index]