| MIL 10 Reference
| Customize Help
| Save Settings

MbufImport



See also
Availability
Available in MIL-Lite with restrictions (see remarks)
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Import data from a file into a data buffer.
Syntax
MIL_ID MbufImport(
MIL_CONST_TEXT_PTR FileName, //in
MIL_INT64 FileFormat, //in
MIL_INT64 Operation, //in
MIL_ID SystemId, //in
MIL_ID *BufIdPtr //in-out
)
Description

This function imports data from a file into an existing or automatically allocated MIL data buffer. The function assumes that the data in the file is in the specified format.

Note, you can also import data using MbufLoad() or MbufRestore(); however, these functions try to determine the format from the data rather than allowing you to specify the format.

For an M_RESTORE operation, this function will allocate the destination buffer with the same attributes as the original buffer, with the exception of an M_IMAGE buffer. In the case of an M_IMAGE buffer, the MbufImport() function tries to allocate the buffer so that it can be used for acquisition (M_GRAB), display (M_DISP), and processing (M_PROC) operations. If there is insufficient appropriate memory to allocate such a buffer, it allocates one that can be used in all of the above operations except for acquisition (M_GRAB). Note that the maximum (total) number of grab (M_GRAB) buffers that can be allocated is restricted by the total amount of MIL non-paged (DMA) memory (specified at installation time or using the MILConfig utility). For systems with on-board processors, the total number of M_GRAB buffers and M_PROC buffers is limited by the amount of on-board memory.

If importing an image, all the pixel information in the file is imported and loaded into the buffer. Additionally, if the file was saved in M_MIL file format and includes any region of interest (ROI) information, the ROI information is also imported and loaded into the buffer when the FileFormat parameter is set to M_MIL. To load the M_MIL file without its ROI information, set FileFormat to M_MIL + M_NO_REGION.

If the vectorial information of an M_VECTOR_AND_RASTER ROI was input in M_WORLD units, the ROI will be imported as an M_VECTOR ROI.

[MIL-Lite with restriction]

When performing an M_RESTORE operation on a file containing compressed data, the buffer will have an M_COMPRESS attribute.

[MIL-Lite with restriction]

When importing compressed data, the following applies. When performing an M_LOAD operation and the destination buffer has an M_IMAGE attribute (but not an M_COMPRESS attribute), this function will automatically decompress it. If necessary, the data in the file will be transformed to the format of the buffer. If unsure of the compression type of the data, use M_DEFAULT as the file format rather than M_JPEG_... or M_JPEG2000_...; the data will be read correctly.

[MIL-Lite with restriction]

When importing uncompressed data into a buffer with an M_COMPRESS attribute, this function will automatically compress it, according to the compression settings found in the buffer.

When importing an image file that has been saved with an associated LUT (color palette) into a 3-band 8-bit image buffer, the LUT is automatically applied to the data to generate 3-band image data. In this case, a LUT buffer is not created and, therefore, is not associated with the 3-band 8-bit buffer. When importing an image file that has been saved with an associated LUT (color palette) into any other type of image buffer, the LUT is also imported and associated with the resulting image buffer. You can obtain the identifier of the associated LUT, using MbufInquire().

Note that the associated LUT will be automatically selected on the display (MdispLut()) if the image buffer is selected on a display and the default LUT has not been overridden by a former call to MdispLut().

Using MbufDiskInquire(), you can inquire about the dimensions of the data saved in a file (except for raw files) without importing it.

After restoring a buffer, we recommend that you check if the operation was successful, using MappGetError(), or by verifying that the returned buffer identifier is not M_NULL.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
FileName

Specifies the name and path of the file from which to import the data. The function handles (internally) the opening and closing of the file.

This parameter can be set to the following value.

function map For specifying the file name and path
CollapseValue Description
Collapse MIL_TEXT("FileName") 1

Specifies the drive, directory, and name of the file, for example, "C:\mydirectory\myfile".

To specify a file on a remote computer (under Distributed MIL), prefix the specified file name string with "remote:///" (for example, "remote:///C:\mydirectory\myfile").

(summarize)

1 If you are passing the value in a variable, don't enclose it in MIL_TEXT().

FileFormat

Specifies the file format. This parameter can be set to one of the following values. Note that except for the M_MIL and M_RAW file formats, data is treated as image data. When performing an M_LOAD operation, the data is internally converted appropriately.

function map For specifying the file format
CollapseValue Description
Collapse M_DEFAULT

Specifies that MIL automatically determines the file format. If the file format is not supported, its data will be treated as raw data.

(summarize)
Collapse M_BMP

Imports image data that is in BMP file format. The standard Windows BMP format is used.

If the specified BMP file contains an image whose image format, data type, and/or depth is not supported by MIL for image buffers, the image will not be imported.

(summarize)
Collapse M_JPEG2000_LOSSLESS
[For essential MIL-Lite information, see remarks ]

Imports a JPEG2000 lossless image.

Collapse M_JPEG2000_LOSSLESS_JP2
[For essential MIL-Lite information, see remarks ]

Imports a JPEG2000 lossless image, as well as the additional JP2 information.

Collapse M_JPEG2000_LOSSY
[For essential MIL-Lite information, see remarks ]

Imports a JPEG2000 lossy image.

Collapse M_JPEG2000_LOSSY_JP2
[For essential MIL-Lite information, see remarks ]

Imports a JPEG2000 lossy image, as well as the additional JP2 information.

Collapse M_JPEG_LOSSLESS
[For essential MIL-Lite information, see remarks ]

Imports a JPEG lossless image.

Collapse M_JPEG_LOSSLESS_INTERLACED
[For essential MIL-Lite information, see remarks ]

Imports a JPEG lossless image stored in two separate fields.

Collapse M_JPEG_LOSSY
[For essential MIL-Lite information, see remarks ]

Imports a JPEG lossy image.

Collapse M_JPEG_LOSSY_INTERLACED
[For essential MIL-Lite information, see remarks ]

Imports a JPEG lossy image stored in two separate fields.

Collapse M_JPEG_LOSSY_RGB
[For essential MIL-Lite information, see remarks ]

Imports a 3-band JPEG lossy image that is in an RGB format.

Collapse M_MIL +

Imports data that is in a MIL file format. The baseline TIFF 6.0 specification is used.

(summarize)
Collapse M_PNG

Imports image data that is in a PNG file format.

Collapse M_RAW

Imports raw data.

Collapse M_TIFF

Imports image data that is in a TIFF file format. The baseline TIFF 6.0 specification is used.

If the specified TIFF file contains an image whose image format, data type, and/or depth is not supported by MIL for image buffers, the image will not be imported.

Multi-page TIFF files can be imported into MIL buffers but only the first page is saved in the buffer. In addition, MIL only supports uncompressed TIFF files.

(summarize)
Combination constants for M_MIL.

You can add one or more of the following values to the above-mentioned value to set whether to import the image with additional information.

Note that you can only specify these values if importing an image (for example, you can specify M_NO_REGION + M_WITH_CALIBRATION).

function map For importing calibration or ROI information
CollapseCombination value Description
Collapse M_NO_REGION

Imports the image, excluding any saved ROI information.

Collapse M_WITH_CALIBRATION

Imports the image, including its calibration information. Note that, this image must have been saved using MbufExport() and it must have a constant pixel size. If the image does not have a constant pixel size, the image will be imported without its calibration information; the target buffer will be uncalibrated. If the image is calibrated and it has a constant pixel size, it is associated with a default uniform calibration context upon being imported into the buffer (as set using McalUniform()). If the image is imported into an existing buffer that is associated with a calibration context, the initial calibration context is replaced by that of the imported image.

(summarize)
Operation

Specifies the import operation. This parameter can be set to one of the following values.

function map For specifying the import operation
CollapseValue Description
Collapse M_LOAD

Imports data from the specified file into a previously allocated MIL data buffer.

Collapse M_RESTORE

Imports data from the specified file into an automatically allocated MIL data buffer. Note, you cannot restore (M_RESTORE) a RAW data file (M_RAW) because its dimensions are unknown.

(summarize)
SystemId

Specifies the system on which to allocate the buffer for an M_RESTORE operation. For an M_LOAD operation, this parameter should be set to M_NULL.

For an M_RESTORE operation, this parameter should be set to one of the following values:

function map For specifying the system on which to allocate the buffer (with M_RESTORE)
CollapseValue Description
Collapse M_DEFAULT_HOST

Specifies the default Host system of the current MIL application.

Collapse MIL system identifier

Specifies a valid system identifier, previously allocated using MsysAlloc().

BufIdPtr

Specifies the address of the variable containing the buffer identifier, for an M_LOAD operation, or the address of the variable in which to store the new buffer identifier, for an M_RESTORE operation.

For an M_LOAD operation, the destination buffer must be large enough in depth and dimensions to hold the data. If the data is deeper than the buffer, the most-significant bits of the data are truncated when loaded into the buffer. If the buffer depth is greater than that of the data, the data is zero or sign-extended (depending on the data type) when loaded into the buffer. If the buffer is larger in size than the data, exceeding areas of the buffer are unaffected.

For an M_RESTORE operation, the destination buffer will be allocated with an appropriate size and type to hold the data. Since MbufImport() also returns the buffer identifier, you can set this parameter to M_NULL. If allocation fails, M_NULL is written as the identifier.

Return value
The returned value is the buffer identifier (for an M_RESTORE operation only). If allocation fails, M_NULL is returned.
Remark
  • [MIL-Lite]
    Note that during development and at runtime, compression support is reliant upon the presence of a compression/decompression package license. This license is only included by default with the development dongle for the full version of MIL. In other cases, this license must be purchased separately.
Compilation information
Header Include mil.h.
Library Use mil.lib.
DLL Requires mil.dll.
DEFAULT BMP JPEG2000 LOSSLESS JPEG2000 LOSSLESS JP2 JPEG2000 LOSSY JPEG2000 LOSSY JP2 JPEG LOSSLESS JPEG LOSSLESS INTERLACED JPEG LOSSY JPEG LOSSY INTERLACED JPEG LOSSY RGB MIL PNG RAW TIFF NO REGION WITH CALIBRATION LOAD RESTORE DEFAULT HOST