This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Mathematica Import/Export Format

BMP (.bmp, .dib, .rle)

MIME type: image/bmp
BMP Windows bitmap format.
Raster image format.
Native bitmap format of the Microsoft Windows operating system.
BMP is an acronym derived from Bitmap.
Binary file format.
Represents images as a true color or indexed color raster at a variety of color resolutions.
Stores data in uncompressed or run-length encoded form.
  • Import["file.bmp"] imports a BMP file, returning a graphics object.
  • Export["file.bmp", expr] exports graphics or any other expression as an image to BMP.
  • Import["file.bmp"] returns an expression of the form Graphics[Raster[data], opts], where data is an array of RGB color values.
  • Export["file.bmp", expr] creates a BMP image with the same image size as the displayed form of expr.
  • Because BMP is a raster image format, all fonts are rasterized on export.
  • Import["file.bmp", elem] imports the specified element from a BMP file.
  • Import["file.bmp", {elem, suba, subb, ...}] imports a subelement.
  • Import["file.bmp", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "BMP"] or Import["file", {"BMP", elem, ...}].
  • Export["file.bmp", expr, elem] creates a BMP file by treating expr as specifying element elem.
  • Export["file.bmp", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each expri as specifying the corresponding elemi.
  • Export["file.bmp", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.bmp", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • In the notebook front end, InsertPicture and the Open menu allow import of a BMP file into a cell.
"Elements" list of elements and options available in this file
"Rules"full list of rules for each element and option
"Options"list of rules for options, properties, and settings
  • Data representation elements:
"Data"array of color values based on the encoding given by "ColorSpace"
"Graphics"Graphics object representing an image
"GrayLevels"array of normalized gray-level values
"RawData"color indices, given as an integer array
"RGBColorArray"array of RGBColor objects
  • Import and Export by default use the "Graphics" element for Windows bitmap files.
  • Export creates a BMP file with indexed color when exporting color-mapped raster graphics or if the "ColorMap" element is specified. Otherwise a true color raster is exported.
"BitDepth"number of bits used to encode a color channel in the file
"ColorDepth"number of bits for each pixel
"ColorMap"color reduction palette used in the file
"ColorSpace"color encoding
"ImageCompression"compression method used in the file
"ImageResolution"resolution at which the graphics should be rendered
  • The BMP format supports the following values for "ColorDepth":
1palette of 2 colors
4color reduction palette of size 16
8color reduction palette of size 256
16RGB at a color resolution of 5 bits per channel
24RGB using 8 bits per channel
32RGB with opacity
  • General option:
ImageSizeAutomaticoverall image size
"ImageTopOrientation"Toporientation of the image as stored in the file
"ImageCompression"Nonewhether to use run-length encoding
  • Possible settings for "ImageCompression" are None and "RLE".