DBPix Documentation
Version 2.0

ImageResample Method


Description:  Resamples the image to new dimensions/resolution.
Syntax:  boolean ImageResample(short Width, short Height, VARIANT_BOOL KeepAspect, ResampleOpType Operation)
Return Value:  
True    The image was resampled successfully.
False    An error occurred.
Arguments:  

Name    Type    Description

Width    short    Maximum width in pixels of the new image.
Height    short    Maximum height in pixels of the new image.
KeepAspect    boolean    Keeps the aspect ratio if True, otherwise stretches the image to fit the Width and Height values exactly.
Operation    ResampleOpType    Controls whether the image may be upsampled only, downsampled only or both.

Enumerations:  
ResampleOpType

Constant    Value    Description

ImageResampleAny    0    Upsample or downsample.
ImageResampleDown    1    Downsample only.
ImageResampleUp    2    Upsample only.

Remarks:  

After resampling the image it will be encoded 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.

'Resampling' is a an image-resizing technique that gives better image quality than a 'simple' resize by 'interpolating' the image to the new resolution. A typical benefit is smoother lines and edges (i.e. no 'jaggies') and smoother color variations in photo-type images.

Resampling can be used to create thumbnails, and other working copies of images at a particular size or resolution. This can be useful if images are added to the system from a wide variety of sources (with different resolutions and image sizes) and the images need to be 'normalized' to a particular size (for display on a web page, for example). It can also be useful if the source images contain much more resolution than the application needs. For example, to display images on-screen it may not be necessary to store a high-res digital-camera image at full resolution (since the screen can only display so many pixels). As well as improving the visual quality of the image at screen resolution, this can save very large amounts of storage space, reduce bandwidth and improve the performance and responsiveness of an application. Of course it may be desirable retain full resolution in order to be able to zoom in and see the detail, and where relevant the original image should be retained or archived so it can be 'repurposed' according to future requirements.


Resampling can be performed automatically when images are loaded, pasted, acquired etc, by setting the ImageResampleMode property. For greater control the ImageResample method can be called from code. This could include customized calculation of the new dimensions (eg based on those of the original image), special handling for portrait or landscape orientations, limiting resampling to only upsampling or downsampling, etc. Both approaches can also be used in batch processes to create 'purposed' images, e.g. batch-importing images into a system, or generating thumbnail and main images for a website.

 

 

Documentation version 2.0.0