The FreeImage Project

The Free, Quality Image library for Windows

ActiveX-Library: Freeimage.Image


Design and implementation by

This file is part of FreeImage 2.6.0

.. back to the main page


Samples

Opening and saving

Option explicit

dim ctrl
dim erg

set ctrl = CreateObject("FreeImage.Image")

ctrl.Test "Opening earth.jpg and saving as a tiff .... ", "FreeImage.Image"

erg = ctrl.Open("earth.jpg")
MsgBox "Opening file result: " + CStr(erg)

erg = ctrl.Save("earth.tif")
MsgBox "Saving file result: " + CStr(erg)

set ctrl = Nothing
 

Cloning

Option explicit

dim ctrl
dim ctrl2
dim erg

set ctrl = CreateObject("FreeImage.Image")

erg = ctrl.Open("earth.jpg")

set ctrl2 = ctrl.Clone

ctrl.Test "first ok", "FreeImage.Image"
ctrl.Test "second ok", "FreeImage.Image"
 

set ctrl2 = Nothing
set ctrl = Nothing

 


Reference

 


Test Shows a Message-Box (for testing and debugging purposes)
in String This string appears in the messagebox (message)
in String This string appears in the messagebox (title)

 

File handling


Open Loads an image. If an image is already opened, it will be closed. The image-format is calculated from the file's extension. If it is unknown, this function will fail.
in String Filename of image to load
out short 0: file couldn't be loaded
1: file sucessfully loaded

OpenEx Loads an image. If an image is already opnened, it will be closed.
If the filetype (extension) of the file is unknown, this function will fail.
in short Image-format
in String Filename of image to load
in short Additional parameter. They are specific to the file-format (e.g. decide which bitmap in the cabinet to load within PCD). See the freeimage-docu or sourcecode for more details! 
out short 0: file couldn't be loaded
1: file sucessfully loaded

Close If an image is opened, it will be closed (without saving it).

Save Saves an opened image. The image will not be closed. The image-format is calculated from the file's extension. If it is unknown or no image is opened, this function will fail.
in String Filename of image to save
out short 0: file couldn't be saved
1: file sucessfully saved

SaveEx Saves an opened image. The image will not be closed. If no image is opened, this function will fail.
in short Image-format
in String Filename of image to save
in short Additional parameter. They are specific to the file-format (e.g. decide which compression-algorithm to save using TIFF or which compression-rate while saving JPEG). See the freeimage-docu or sourcecode for more details!
out short 0: file couldn't be saved
1: file sucessfully saved

 

Image-Information

If no image is opened, the following functions and properties will fail.


ResolutionX The horizontal image-resolution .
get/set double Resolution in [dpi]

ResolutionY The vertical image-resolution .
get/set double Resolution in [dpi]

Width The width of the image.
get long Width

Height The height of the image.
get long Height

BPP Returns the size of one pixel in the bitmap in bits. For example when each pixel takes 32-bits of space in the bitmap, this function returns 32.
get long BPP
1: b/w
4, 8: palette
16, 24, 32: full-coored image

DIBSize

Returns the size of the DIB-element of a opened image in memory. E.g. the BITMAPINFOHEADER + palette + data bits.

get long  

RedMask

Returns a bit pattern describing the red colour component of a pixel in an opened image.

get long  

GreenMask

dto.

get long  

BlueMask

dto.

get long  

ColorsUsed

Returns the number of colours used in a bitmap. This function returns the palette-size for palletised bitmaps, and 0 for high-colour bitmaps.
Note: It doesn’t return the actual number of colors being used in a bitmap, but the size of the palette.

get long  

IsTransparent Status of the transparency-table.
get short 1: transparency table is enabled
0: else

 

Image-Conversions


ChangeColors Changes the color-model (BPP). If no image is opened or the conversion fails, this function will fail.
in short New BPP:
1: convert ot b/w (not yet implemented!)
8: Converts a bitmap to 8 bits. If the bitmap was a high-colour bitmap, the end result will be grayscale.
256: Quantizes a high-color bitmap to an 8-bit palletised bitmap. See the additional parameter.
16: Converts a bitmap to 16 bits. See the additional parameter.
24: Converts a bitmap to 24 bits.
32: Converts a bitmap to 32 bits.
in short Additional parameter. Depends on the New BPP-paramter.

For 256:
0: Xiaolin Wu color quantization algorithm
1: NeuQuant neural-net quantization algorithm by Anthony Dekker

For 16:
0 or 555: Each pixel has a colour pattern of 5 bits red, 5 bits green and 5 bits blue. One bit in each pixel is unused.
565: Each pixel has a colour pattern of 5 bits red, 6 bits green and 5 bits blue.
out short 0: Failed
1: Successfully changed BPP
2: Color-model already had the specified characteristics.

Clone Duplicates. A new image is generated. If no image is opened or the cloning fails, this function will fail.
out Reference to a new Freeimage.Image