DBPix Documentation
Version 2.0

ImageLoadBlob Method


Description:  Loads an image from a Variant containing the raw image data (e.g. a variable or recordset data).
Syntax:  boolean ImageLoadBlob(VARIANT ImageBlob)
Return Value:  
True    The image was loaded successfully.
False    An error occurred.
Arguments:  

Name    Type    Description

ImageBlob    Variant    Variant containing the image data.

Remarks:  

After decoding the image it will be resampled (resized) if specified by the ImageResampleMode property, then encoded according to the ImageSaveFormat property (and any relevant format-specific property settings for JPEG, PNG etc).

The ImageModified. and ImageChanged events will be fired, and if DBPix is bound to a data-source the source will be updated.

To prevent recompression of JPEG images (and avoid unnecessary JPEG 'generational loss') see the JPEGNoRecompress property (ImageResampleMode must also be set to ImageResampleModeOriginal [1]).

To simply display an image from a Variant, use the ImageViewBlob method, or simply assign the data to the image property, e.g.

    DBPixCtrl.Image = varImg
or:
    DBPixCtrl.Image = rs("ImageField")

A common use for ImageLoadBlob is when creating thumbnails. A typical configuration uses 2 DBPix controls - one for the main image and one for the thumbnail. Whenever the 'Main' image is modified the thumbnail should be updated, for example:

Private Sub DBPixMain_ImageModified()
    ' The main image has been changed, so update the thumbnail
    DBPixThumb.ImageLoadBlob (DBPixMain.Image)
End Sub


Note that in an 'unbound' or 'external-files' design, the file/data would also need to saved/stored, which may be done during this event or later.

An alternative technique is to use the clipboard to copy the image from the 'Main' control then paste into the 'Thumbnail' control. This may be slightly faster, but overwrites whatever the user may have on the clipboard.

 

 

Documentation version 2.0.0