SaveBuffer method (ILEADRasterIO)

Visual Basic example

Visual C++ 5.0 example

 

Syntax

short SaveBuffer(ILEADRaster *pRaster, RasterFileConstants Format, short iBitsPerPixel, QFactorConstants Quality, short iModify);

Overview

Refer to Using Memory-Resident Image Files.

Remarks

Saves a bitmap to a file in memory. It is up to the user to allocate the memory that will hold the bitmap file. If the memory allocated by the user is not large enough to accommodate the image, the SaveBuffer event will be fired so that the memory location can be reallocated.

It is advisable to set the EnableSaveBufferEvent property to TRUE so that the SaveBuffer event can be fired. If the EnableSaveBufferEvent property is set to FALSE and the allocated memory is not large enough to accommodate the image, the SaveBuffer event will not be fired and the method will fail.

Note that this method is different from the SaveArray method and SaveMemory method in that the user is completely responsible for allocating the memory to hold the bitmap file. To avoid having to handle the allocating/deallocatingof the memory, use either the SaveArray method or the SaveMemory method.

An overview of the process follows:

1.

Set the EnableSaveBufferEvent property to TRUE.

2.

Allocate a section of memory.

3.

Set the SaveBufferAddress property to the address of the allocated memory.

4.

Set the SaveBufferSize property equal to the size of the allocated memory.

5.

Call the SaveBuffer method.

6.

In the SaveBuffer event, reallocate the memory to be AT LEAST as large as the size requested by the event. Then set the SaveBufferAddress property to the address of the memory location (if it has changed), and set the SaveBufferSize to the size of the reallocated memory buffer. If you cannot reallocate the required memory size, set the EnableSaveBufferEvent property to FALSE to cause the SaveBuffer method to abort.

7.

When you are finished using the file in memory, free the memory that you have allocated.

The output can be in any of the supported compressed or uncompressed file formats.

To see the correct data types, refer to the code example for your development system.

To load an image from a file in memory, use one of the following methods:

LoadMemory—use this for a global handle to the file in memory

LoadArray—use this for a VARIANT byte array that contains the file in memory

LoadBuffer—use this for an address of a memory location that contains the file in memory

To save an image to a memory file, use one of the following methods:

SaveMemory—returns a global handle to a file in memory

SaveArray—returns a VARIANT byte array that contains the file in memory

SaveBuffer—saves a file into a memory location that the user allocates

Support for 12 and 16-bit grayscale images is available only in the Document/Medical toolkits.

For a list of available products, refer to Summary of LEADTOOLS Products.

This method does not support signed data images, but only DICOM images are supported as signed data. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image, other than a DICOM image, is passed to this method.

For information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.

See Also

Elements

SaveBufferSize property, SaveBufferAddress property, EnableSaveBufferEvent property, LoadArray method, LoadMemory method, LoadBuffer method, SaveArray method, SaveMemory method, Save method, SaveTileHeight property, SaveTileWidth property

Topics

Raster Images: Saving Files

 

Saving a Region