BMP (.bmp, .dib)

Background & Context

    • 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.
    • Stores color bitmaps at a variety of color resolutions.
    • Allows different bit depths in different channels.
    • Has support for color reduction palettes using up to 256 8-bit RGB colors.
    • Supports transparency.
    • Stores data in uncompressed or run-length encoded form.

Import & Export

  • Import["file.bmp"] imports a BMP file, returning an Image object.
  • Import["file.bmp",elem] imports the specified element from a BMP file.
  • The import format can be specified with Import["file","BMP"] or Import["file",{"BMP",elem,}].
  • Export["file.bmp",expr] exports graphics or any other expression as an image to BMP.
  • Notebook and Cell expressions can be exported to BMP.
  • When exporting Wolfram Language graphics or arbitrary expressions to BMP, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because BMP is a raster image format, all fonts are rasterized on export.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Notebook Interface

  • In the notebook front end, Insert Picture and the Open menu allow import of a BMP file into a cell.
  • Save Selection As exports the selected part of a notebook as a BMP file.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Data"array of color values based on the encoding given by "ColorSpace"
    "Graphics"Graphics object representing an image
    "Image"raster image, given as an Image object
    "RawData"color indices, given as an integer array
  • Import and Export by default use the "Image" element for Windows bitmap files.
  • Export automatically selects the most appropriate type of BMP file to store binary, grayscale, and color images.
  • Export creates a BMP file with indexed color when exporting color-mapped raster graphics or if the "ColorMap" element is specified.
  • Advanced Import elements:
  • "BitDepth"number of bits used to encode a color channel in the file
    "Channels"the number of color channels used 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
    "ImageSize"size of the imported BMP
    "Summary"summary of the file
  • 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
    16typically 5 bits per color channel
    24RGB using 8 bits per channel
    32typically 8-bit RGB with opacity

Options

  • Import and Export option:
  • ImageSizeAutomaticoverall image size
    "ImageTopOrientation"Toporientation of the image as stored in the file
  • Export option:
  • "ImageCompression"Nonewhether to use run-length encoding
  • Possible settings for "ImageCompression" are None and "RLE".

Examples

open allclose all

Basic Examples  (3)

Import a BMP file:

Summary of an image:

Export raster graphics to BMP:

Scope  (3)

Export a binary image to BMP:

Export rasterized vector graphics to BMP:

Export a rasterized Wolfram Language expression to BMP:

Import Elements  (2)

Available Elements  (2)

List of available elements:

Import all elements as a list of rules: