ImageMan ActiveX
Saving Images to Memory

Images can be saved to memory in any support image format using the %hImageData:IMACTX8~ImageControl~hImageData% , %MemoryFormat:IMACTX8~ImageControl~MemoryFormat% and %ImageDataSize:IMACTX8~ImageControl~ImageDataSize% properties.

 

Saving an image to memory first requires that the %MemoryFormat:IMACTX8~ImageControl~MemoryFormat% property be set to the 3-letter extension of the desired image format. Querying the %hImageData:IMACTX8~ImageControl~hImageData% property will return a handle to a globally allocated memory block that contains the image data in the requested format. Each time the %hImageData:IMACTX8~ImageControl~hImageData% property is queried a new memory block will be allocated. It is the responsibility of the application to free the memory allocated by using the Windows API function, GlobalFree(). After querying %hImageData:IMACTX8~ImageControl~hImageData%, the %ImageDataSize:IMACTX8~ImageControl~ImageDataSize% property will return the size of the written image data in bytes.

 

The following code loads and image and then saves it to memory in JPG format.

 

ImageControl1.Picture = "c:\test.tif"

ImageControl1.MemoryFormat = "JPG"

hMem = ImageControl1.hImageData

ImageSize = ImageControl1.ImageDataSize

' hMem now contains the image data and ImageSize is the size in bytes of the image ' data

' When done with the block free it

GlobalFree hMem

 


 

 


© 2014 Data Techniques, Inc. All rights reserved.

Submit feedback on this topic