This method saves image data as raw data.
Parameters
Val
The image format used to save the image
This value is of type Newtone.ImageKit.WPF.SaveFileType
SaveImage
The saved image (type is
System.Drawing.Image)
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The SaveImageToRawData method saves image data as raw data.
When the SaveImage parameter contains a valid image handle
The image set in the SaveImage parameter will be saved as raw data and set into the RawData property.
When the SaveImage parameter contains 0
The image referred to by the LayerNumber property (either the image set in the Image property or the image set in the Layer(LayerNumber).Image property as the case may be) will be saved as raw data and set into the RawData property.
Note: When the LayerNumber property is -1, the image set in the Image property is enabled. When the LayerNumber property has values from 0 to 99, the image set in the Layer(LayerNumber).Image property is enabled.
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 WPF Plugin (Win32 Dll files) Note: When the ImageKit WPF 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 WPF 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 WPF 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 |
Note: Tiff Group3-1D images are the same as MH format. Tiff
Group4 images are the same as MMR format. Uncompressed Tiff and LZW
compressed 16 bit images will be converted to 24 bit color when
saved.
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.SaveImageToRawData(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.SaveImageToRawData(Newtone.ImageKit.SaveJPEG, null);