creation
The following routines are used to create and destroy bitmaps:
a32Dib0 dib = newDib(integer width, integer height)
a32Dib0 destdib = copyDib(a32Dib srcdib)
a32Dib0 newdib = extractDib(object src, integer x1, integer y1, integer x2, integer y2)
a32Dib0 newdib = loadDib(string fileName)
integer r = saveDib(a32Dib dib, string fileName, integer x1, integer y1, integer x2, integer y2)
integer r = saveDibGray(a32Dib dib, string fileName, integer x1, integer y1, integer x2, integer y2)
integer r = saveDibReduced(a32Dib dib, string fileName, integer x1, integer y1, integer x2, integer y2)
killDib(a32Dib dib)
You can load a bitmap from a BMP file with the loadDib function.
You can save (a region of) the bitmap to a 24-bit BMP file with the saveDib function,
which returns 0 if successful, or 1 if the bitmap could not be saved.
You can also save (a region of) the bitmap as an 8-bit grayscale BMP file with the
saveDibGray function (same parameters and return value like saveDib), or
as an 8-bit websafe color BMP file with the saveDibReduced function.
Example:
integer result
a32Dib0 dib
dib = loadDib("bitmap1.bmp") -- loads the bitmap
if integer(dib) then
... -- could not load the bitmap
abort(0)
end if
-- save the rectangular region {10, 10} -> {100, 75} to the file "bitmap2.bmp".
result = saveDib(dib, "bitmap2.bmp", 10, 10, 100, 75)
if result!=0 then
... -- the bitmap could not be saved
end if
See Also:
getDibFromClipboard