The Bitmap structure contains functions and structures to create and operate on bitmaps. Bitmaps are rectangular pictures in which the colour values for each pixel are given individually. They are often used as the basis for icons. There are two forms of bitmap: device-dependent bitmaps represented by the bitmap handle, HBITMAP, and device-independent bitmaps.
structure Bitmap:
sig
type HBITMAP and HDC
type COLORREF = Color.COLORREF
type RECT = { top: int, left: int, bottom: int, right: int }
type SIZE = { cx: int, cy: int }
datatype BitmapCompression = BI_BITFIELDS | BI_RGB | BI_RLE4 | BI_RLE8
datatype FloodFillMode = FLOODFILLBORDER | FLOODFILLSURFACE
type BITMAP =
{ width: int, height: int, widthBytes: int, planes: int, bitsPerPixel: int,
bits: Word8Vector.vector option }
type StretchMode
val BLACKONWHITE : StretchMode
val COLORONCOLOR : StretchMode
val HALFTONE : StretchMode
val MAXSTRETCHBLTMODE : StretchMode
val WHITEONBLACK : StretchMode
type RasterOpCode
val BLACKNESS : RasterOpCode
val DSTINVERT : RasterOpCode
val MERGECOPY : RasterOpCode
val MERGEPAINT : RasterOpCode
val NOTSRCCOPY : RasterOpCode
val NOTSRCERASE : RasterOpCode
val PATCOPY : RasterOpCode
val PATINVERT : RasterOpCode
val PATPAINT : RasterOpCode
val SRCAND : RasterOpCode
val SRCCOPY : RasterOpCode
val SRCERASE : RasterOpCode
val SRCINVERT : RasterOpCode
val SRCPAINT : RasterOpCode
val WHITENESS : RasterOpCode
val BitBlt : HDC * int * int * int * int * HDC * int * int * RasterOpCode -> unit
val CreateBitmap :
{bits: Word8Vector.vector option, width: int, height: int,
planes: int, bitsPerPixel: int} -> HBITMAP
val CreateBitmapIndirect : BITMAP -> HBITMAP
val CreateCompatibleBitmap : HDC * int * int -> HBITMAP
val ExtFloodFill : HDC * int * int * COLORREF * FloodFillMode -> unit
val GetBitmapBits : HBITMAP * int -> Word8Vector.vector
val GetBitmapDimensionEx : HBITMAP -> SIZE
val GetPixel : HDC * int * int -> COLORREF
val GetStretchBltMode : HDC -> StretchMode
type QuaternaryRop
val MAKEROP4 : {back: RasterOpCode, fore: RasterOpCode} -> QuaternaryRop
val MaskBlt :
HDC * int * int * int * int * HDC * int * int *
HBITMAP * int * int * QuaternaryRop -> unit
val PlgBlt : HDC * RECT * HDC * RECT * HBITMAP * int * int -> unit
val SetBitmapBits : HBITMAP * Word8Vector.vector -> unit
val SetBitmapDimensionEx : HBITMAP * int * int * SIZE -> SIZE
val SetPixel : HDC * int * int * COLORREF -> COLORREF
val SetStretchBltMode : HDC * StretchMode -> unit
val StretchBlt :
HDC * int * int * int * int * HDC * int * int * int * int * RasterOpCode -> unit
type BITMAPINFOHEADER =
{
width: int, height: int, planes: int, bitsPerPixel: int,
compression: BitmapCompression, sizeImage: int, xPelsPerM: int,
yPelsPerM: int, clrUsed: int, clrImportant: int
}
val getBitmapInfoHdr: Word8Vector.vector -> BITMAPINFOHEADER
val GetDIBits: HDC * HBITMAP * int * int * BITMAPINFOHEADER option -> Word8Vector.vector
val SetDIBits: HDC * HBITMAP * int * int * Word8Vector.vector -> unit
end
A device-independent bitmap contains information which allows it to be written to a file and read in on a different machine with different numbers of bits per pixel. It can also be passed on the clipboard using the CH_DIB clipboard format. A device-independent bitmap is simply a vector of bytes and is represented in ML by the Word8Vector.vector type.
getBitmapInfoHdr(vec: Word8Vector.vector):
BITMAPINFOHEADER
ML Extension: Extracts the header from a vector containing a
device-independent bitmap. It is often necessary to extract the header from a
device-independent bitmap in order to find the size of the bitmap needed as the argument
to SetDIBits.
GetDIBits(hdc, hb, startScan, scanLines, binfo:
BITMAPINFOHEADER option): Word8Vector.vector
Extracts a bitmap as a device-independent bitmap. This function operates in two
modes according to whether the binfo argument is NONE or SOME. If NONE is passed it
returns only the header. This can be extracted with getBitmapInfoHdr and if
necessary a modified copy of it can be made. For example, the bitsPerPixel can be
changed from the default for the device. It can then be passed with SOME again to
GetDIBits to extract the full device-independent bitmap.
SetDIBits(hdc, hb, startScan, scanLines, vec:
Word8Vector.vector): unit
Sets a bitmap to the device-independent bitmap in the argument vector.