Read bitmap data
This functionality does not run in MATLAB.
ReturnType = DOM_HFARRAY | DOM_ARRAY | DOM_LIST>)
import::readbitmap is used for reading ASCII
or binary data files storing bitmap images of pictures. The following
standard graphical formats can be read: BMP, DCX, DDS, WAD, GIF, ICO,
JPG, LIF, MDL, PCD, PCX, PIC, PIX, PNG, PNM, PSD, PSP, PXR, RAW, SGI,
TGA, TIF, WAL, XPM. The format of the pixel data is determined automatically
from the contents of the file. The return value
[w, h, colordata] provides
the pixel height
h, the pixel width
and the color data of the bitmap image.
Either the complete return value or just the third element,
can be passed to the function
plot::Raster to generate a plot object
that can be used in a MuPAD® graphics. E.g., the command
creates a MuPAD graphics of the bitmap stored in the JPG
Most of the standard graphical formats store the pixel data
row by row in the usual reading order starting with the upper left
corner of the image. The pixel data in the returned array
The interpretation of the other return types is analogous, see below for details on the return types.
This is consistent with the interpretation of a color array
import::readbitmap(filename) searches for
the file in various directories:
First, the name is interpreted as a relative file
filename is concatenated to each directory
given by the environment variable
Then the file name is interpreted as an absolute path name.
Then the file name is interpreted relative to the "working directory."
Last, the file name is concatenated to the directory path.
If a file can be opened with one of this names, then the file is read.
Note that the meaning of "working directory" depends on the operating system. On Microsoft® Windows® systems and on Apple Mac OS X systems, the "working directory" is the folder where MuPAD is installed. On UNIX® systems, it is the current working directory in which MuPAD was started; when started from a menu or desktop item, this is typically the user's home directory.
A path separator ("/") is inserted as necessary
when concatenating a given path and
import::readbitmap does not accept file
handles returned by
Nor can it handle files which have been compressed by
but since most bitmap formats employ high quality compression in any
case, there is little reason to try compressing them again in any
We import a PGM (portable graymap) picture:
[w, h, Norton] := import::readbitmap("Norton.pgm"):
The bitmap image is to be embedded in a MuPAD graphics.
We use the width
w and the height
place the bitmap in a rectangle whose sides have the same ratio as
the original bitmap. With
Scaling = Constrained we
make sure that this aspect ratio is also used in the final graphics:
xmin := 2: xmax := xmin + w/100: ymin := 0.5: ymax := ymin + h/100: plot(plot::Function2d(x*sin(PI/x), x = -1..4.5, AdaptiveMesh = 2), plot::Raster(Norton, x = xmin ..xmax, y = ymin .. ymax), Scaling = Constrained, Footer = "Work And Play"):
The file name: a non-empty character string
Option, specified as
Set the type of the actual color data returned as
If set to
If set to
If set to
[w, h, colordata].
w is the pixel width of the bitmap.
h is the pixel height of the bitmap.
of the bitmap. Its type depends on the setting of the option