This method saves image data to a file.

[C++Builder]   [ bool = ]imagekitcontrolname->FileIO->SaveFile(TVIkSaveFile SaveType, NativeUInt ImageHandle)
[C++Builder]   [ bool = ]imagekitcontrolname->FileIO->SaveFile(TVIkSaveFile SaveType)
[Delphi]   [ Boolean = ]imagekitcontrolname.FileIO.SaveFile(SaveType: TVIkSaveFile; ImageHandle: THandle)
[Delphi]   [ Boolean = ]imagekitcontrolname.FileIO.SaveFile(SaveType: TVIkSaveFile)

[TVIkSaveFile Type]

Unit
     IkInit

type
 TVIkSaveFile = (vikSaveBMP, vikSaveBMPRLE, vikSaveJPEG, vikSaveJPEGProgress, vikSaveGIF, vikSaveTIFFNoncompressed, vikSaveTIFFCcittrle, vikSaveTIFFGroup3_1D, vikSaveTIFFGroup3_2D, vikSaveTIFFGroup4, vikSaveTIFFPackbits, vikSaveTIFFLZW, vikSavePNG, vikSaveFPXNoncompressed, vikSaveFPXSingleColor, vikSaveFPXJpeg, vikSavePCX, vikSaveWMF, vikSaveEMF, vikSaveDXF, vikSaveSVG, vikSaveJPEG2000, vikSaveJPEG2000Stream, vikSaveSXFP21, vikSaveSXFSFC, vikSaveTIFFJPEG, vikSaveJPEGExif, vikSaveJPEGProgressExif);

Parameters

Name Explanation
SaveType vikSaveBMP (uncompressed BMP)
vikSaveBMPRLE (compressed BMP
vikSaveJPEG(JPEG Standard DCT)
vikSaveJPEGProgress(JPEG Progressive DCT)
vikSaveGIF(GIF)
vikSaveTIFFNoncompressed(uncompressed TIF)
vikSaveTIFFCcittrle(TIFF CCITTRLE)
vikSaveTIFFGroup3_1D(TIFF GROUP3-1D)
vikSaveTIFFGroup3_2D(TIFF GROUP3-2D)
vikSaveTIFFGroup4(TIFF GROUP4)
vikSaveTIFFPackbits(TIFF PACKBITS)
vikSaveTIFFLZW(TIFF LZW)
vikSavePNG(PNG)
vikSaveFPXNoncompressed(FPX Uncompressed)
vikSaveFPXSingleColor(FPX Single color compression)
vikSaveFPXJpeg(FPX JPEG Compression)
vikSavePCX(PCX)
vikSaveWMF(WMF)
vikSaveEMF(EMF)
vikSaveDXF(DXF)
vikSaveSVG(SVG)
vikSaveJPEG2000(JPEG2000 Part1)
vikSaveJPEG2000Stream(JPEG2000 Code Stream)
vikSaveSXFP21(SXF p21)
vikSaveSXFSFC(SXF sfc)
vikSaveTIFFJPEG(TIFF JPEG)
vikSaveJPEGExif(Exif JPEG Standard DCT)
vikSaveJPEGProgressExif(Exif JPEG Progressive DCT)
ImageHandle The image handle of the image data to be saved

Return Value

Returns True if successful. Returns False if unsuccessful.

Explanation

The SaveFile method saves image data to a file.

When the ImageHandle parameter contains a valid image handle

The image set in the ImageHandle parameter will be saved in the location specified by the FileName property.

When the ImageHandle parameter is not used or contains 0

The image referred to by the LayerNo property (either the image set in the ImageHandle property or the image set in the Layer(LayerNo).ImageHandle property as the case may be) will be saved in the location specified by the FileName property.

Below is a list of other properties that should be set when saving files in the these formats...

FPX The Comment property should be set. If the SaveType parameter is vikSaveFPXJpeg then the JpegQuality property should also be set.
GIF The Comment, GifAnime, GifAnimeDelay, Interlace, PalBlue, PalGreen, PalRed, and Transparent properties should be set.
JPEG The Comment, JpegQuality, and JpegSubsamp properties should be set.
JPEG2000 The Comment, JPEG2000CodeBlockHeight, JPEG2000CodeBlockWidth, JPEG2000NumrResLevel, JPEG2000PrecinctHeight, JPEG2000PrecinctWidth, JPEG2000Reversible, JPEG2000Size, JPEG2000TileHeight, and JPEG2000TileWidth properties should be set.
PNG The Comment, Interlace, PalBlue, PalGreen, PalRed, PngAlphaChannel, and Transparent properties should be set. When the PngAlphaChannel property is True, pass the image handle of the 32 bit RGBA image to the ImageHandle property.
TIFF The Comment and TiffAppend properties should be set. If the SaveType = vikSaveTIFFNoncompressed, vikSaveTIFFPackbits, vikSaveTIFFLZW then the TiffColorSpace property should be set. If SaveType = vikSaveTIFFJPEG, then the JpegQuality should be set. For all Tiff images other than GROUP4, the TiffSaveOneStrip property should be set.
Exif Exif

 

In order to save vector image data as raster image data, the Vector.VectorToRaster method must be executed PRIOR to executing the SaveFile method. In other words, the vector image data must be converted to DIB image data before it can be saved in a raster image format.

To display a caption, message, and button in the Progress dialog box when loading or saving files, set the Caption, Message and ButtonName properties.


With certain raster image formats, it is only possible to save images of a particular bitcount. Errors can be generated if an image of unsupported bitcount is saved. Below is a list of supported bitcounts when saving each type of raster image.

Name Explanation
BMP (Uncompressed) 1, 4, 8, 16, 24, 32 (Does not include 16 bit grayscale)
BMP (Compressed) 4,8
JPEG (Standard DCT) 8 bit grayscale, 24
JPEG (Progressive DCT) 8 bit grayscale, 24
GIF 1, 4, 8
TIFF (Uncompressed) 1, 4, 8, 16, 24, 32 (Does not include 16 bit grayscale)
TIFF (CCITTRLE) 1
TIFF (GROUP3-1D) 1
TIFF(GROUP3-2D) 1
TIFF (GROUP4) 1
TIFF (LZW) 1, 4, 8, 16, 24, 32 (Does not include 16 bit grayscale)
TIFF (PACKBITS) 1, 4, 8, 16, 24, 32 (Does not include 16 bit grayscale)
TIFF (JPEG) 8 bit grayscale, 24
PNG 1,4,8,24
FPX (Uncompressed) 8 bit grayscale, 24
FPX (Single Color Compressed) 8 bit grayscale, 24
FPX (JPEG Compression) 8 bit grayscale, 24
PCX 1,4,8,24
JPEG2000(Part1) 8 bit grayscale, 24
JPEG2000(Code Stream) 8 bit grayscale, 24
Exif (Standard DCT) 8 bit grayscale, 24
Exif (Progressive DCT) 8 bit grayscale, 24

Note: TIFF GROUP3-1D is the same as MH. TIFF GROUP3-2D is the same as MR. TIFF GROUP4 is the same as MMR. If images are saved in uncompressed TIFF, TIFF PACKBITS, or TIFF LZW formats as 16 bit images, they will be converted to 24 bit.

Sample code for converting a BMP image file into a 24 bit JPEG image file

C++Builder

VImageKit1->FileIO->FileName = "Newtone.bmp";
VImageKit1->LayerNo = -1;
if (VImageKit1->FileIO->LoadFile(vikLoadBMP) == false) return;
if (VImageKit1->GetImageType() == false) return;
if (VImageKit1->BitCount != 24)
{
     if (VImageKit1->Effect->ConvertColor(24, false, false, 0) == false) return;
}
VImageKit1->FileIO->JpegQuality = 75;
VImageKit1->FileIO->JpegSubsamp = vik411;
VImageKit1->FileIO->FileName = "Newtone.jpg";
VImageKit1->FileIO->SaveFile(vikSaveJPEG);

Delphi

VImageKit1.FileIO.FileName := 'Newtone.bmp';
VImageKit1.LayerNo := -1;
if VImageKit1.FileIO.LoadFile(vikLoadBMP) = False then Exit;
if VImageKit1.GetImageType() = False then Exit;
if VImageKit1.BitCount <> 24 then
begin
     if VImageKit1.Effect.ConvertColor(24, False, False, 0) = False then Exit;
end;
VImageKit1.FileIO.JpegQuality := 75;
VImageKit1.FileIO.JpegSubsamp := vik411;
VImageKit1.FileIO.FileName := 'Newtone.jpg';
VImageKit1.FileIO.SaveFile(vikSaveJPEG);

Differences from the ImageKit7/8/9/10 ActiveX

The VCL constants contain a "v". In ActiveX, the constants are: ikSaveBMP, ikSaveBMPRLE, ikSaveJPEG, ikSaveJPEGProgress, ikSaveGIF, ikSaveTIFFNoncompressed, ikSaveTIFFCcittrle, ikSaveTIFFGroup3_1D, ikSaveTIFFGroup3_2D, ikSaveTIFFGroup4, ikSaveTIFFPackbits, ikSaveTIFFLZW = 11, ikSavePNG, ikSaveFPXNoncompressed, ikSaveFPXSingleColor, ikSaveFPXJpeg, ikSavePCX, ikSaveWMF, ikSaveEMF, ikSaveDXF, ikSaveSVG, ikSaveJPEG2000, ikSaveJPEG2000Stream, ikSaveSXF P21, ikSaveSXFSFC, ikSaveTIFFJPEG, ikSaveJPEGExif = 26, ikSaveJPEFProgressExif

The ImageKit10 VCL is a product created by Newtone Corporation