This methods saves image data to a file.
Public Function SaveImageToFile(Val As SaveFileType, SaveImage As Image) As Boolean
public bool SaveImageToFile(SaveFileType Val, Image SaveImage) ;
Parameters
Val
The image format used to save the
image
This value is of type SaveFileType
SaveImage
The saved image
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The SaveImageToFile method saves image data to a file. The image set in the SaveImage parameter will be saved in the location specified by the FileNameproperty.
Below is a list of other properties that should be set when saving files in the these formats...
Format | Explanation |
---|---|
FPX | The Comment property should be set. If the Val parameter is SaveFPXJpeg then the JpegQuality property should also be set. |
GIF | The Comment property should be set. |
JPEG | The Comment, JpegQuality, and JpegSubsampling properties should be set. |
JPEG Progress | The Comment, JpegQuality, and JpegSubsampling properties should be set. |
JPEG2000 | The Comment, JPEG2000CodeBlockHeight, JPEG2000CodeBlockWidth, JPEG2000NumResLevel, JPEG2000PrecinctHeight, JPEG2000PrecinctWidth, JPEG2000Reversible, JPEG2000Size, JPEG2000TileHeight, and JPEG2000TileWidth properties should be set. |
PNG | The Comment property should be set. |
TIFF | The TiffAppend property should be set. After the image has been saved, please execute the CloseMultiTiff method. |
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) | 24 bit color. 8 bit grayscale
may be saved only with the ImageKit.NET Plugin (Win32 Dll
files) Note: When the ImageKit.NET Plugin (Win32 Dll files) are present, 8 bit grayscale and 24 bit color images can be saved in JPEG. Attempting to save images of other bitcounts will result in an error. If the ImageKit.NET Plugin (Win32 Dll files) are not present, all images will be converted to 24 bit color and saved in JPEG. |
JPEG (Progressive DCT) | 8 bit grayscale, 24 |
GIF | 1, 4, 8 Note: If the ImageKit.NET Plugin (Win32 Dll files) are not present, all images will be saved in 8 bit GIF |
TIFF (Uncompressed) | 1, 4, 8, 16, 24 (Does not include 16 bit grayscale) |
TIFF (GROUP3-1D) | 1 |
TIFF (GROUP4) | 1 |
TIFF (PACKBITS) | 1 |
TIFF (LZW) | 1, 4, 8, 16, 24 (Does not include 16 bit grayscale) |
TIFF (JPEG) | 1, 4, 8, 16 (Does not include 16 bit grayscale),
24, 32 * Although the above bitcounts are supported, the saved image will be 24 bit color |
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 |
JPEG2000 (Part1) | 8 bit grayscale, 24 |
JPEG2000 (Code Stream) | 8 bit grayscale, 24 |
Note: The following image formats are not supported by standard
.NET Framework. Therefore, the ImageKit.NET Plugin (Win32 Dll
files) are required when saving images in: BMP Compressed, Saving
Jpeg 8 bit grayscale, JpegProgressive, JPEG2000,
FPX file formats.
WMF and EMF images cannot be read and displayed in standard .NET
framework but rather are converted to raster image data and
displayed. As such, even though the file extensions are .wmf or
.emf, these images can only be saved as raster images.
Example
Sample code for converting a BMP image file into a 24 bit JPEG image file:
[Visual Basic.NET] ImageKit1.File.FileName = "Newtone.bmp" If ImageKit1.File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.LoadBMP) = False Then Exit Sub If ImageKit1.GetImageType() = False Then Exit Sub If ImageKit1.BitCount <> 24 Then If ImageKit1.Effect.ConvertColor(24, False, False, 0) = False Then Exit Sub End If ImageKit1.File.FileName = "Newtone.jpg" ImageKit1.File.SaveImageToFile(Newtone.ImageKit.SaveFileType.SaveJPEG, Nothing) [Visual C#.NET] ImageKit1.File.FileName = "Newtone.bmp"; if (!ImageKit1.File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.LoadBMP)) return; if (!ImageKit1.GetImageType()) return; if (ImageKit1.BitCount <> 24)) { if (!ImageKit1.Effect.ConvertColor(24, false, false, 0)) return; } ImageKit1.File.FileName = "Newtone.jpg"; ImageKit1.File.SaveImageToFile(Newtone.ImageKit.SaveFileType.SaveJPEG, null);