This method saves image data as raw data.
Public Function SaveImageToRawData(Val As SaveFileType, SaveImage As Image) As Boolean
public bool SaveImageToRawData(SaveFileType Val, Image SaveImage) ;
Parameters
Val
The format of image to be saved
The value is of type SaveFileType
SaveImage
The saved image
Return Value
Returns True if successful. Returns False if unsuccessful.
Explanation
The SaveImageToRawData method saves image data as raw data.
The image set in the SaveImage parameter will be saved as raw data and set into the RawData 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 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. |
Though there are differences when saving raw image data, the process is nearly the same as the SaveImageToFile 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.NET2 Plugin (Win32 Dll files) |
JPEG (Progressive DCT) | 8 bit grayscale, 24 |
GIF | 1, 4, 8 Note: If the ImageKit.NET2 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 |
PCX | 1,4,8,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.NET2 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 and saving it as raw data:
[Visual Basic.NET] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim LoadImg As Image Dim Ik_File As Newtone.ImageKit.WPF.IkFile Ik_File = New Newtone.ImageKit.WPF.IkFile Ik_File.FileName = "Newtone.bmp" LoadImg = Ik_File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.LoadBMP) If LoadImg = Nothing Then Exit Sub Ik_File.FileName = "Newtone.jpg" Ik_File.SaveImageToRawData(Newtone.ImageKit.SaveFileType.SaveJPEG, LoadImg) End Sub [Visual C#.NET] private void button1_Click(object sender, System.EventArgs e) { Newtone.ImageKit.WPF.IkFile Ik_File = new Newtone.ImageKit.WPF.IkFile(); Ik_File.FileName = "Newtone.bmp"; Image LoadImg = Ik_File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.LoadBMP); if (LoadImg == null) return; Ik_File.FileName = "Newtone.jpg"; Ik_File.SaveImageToRawData(Newtone.ImageKit.SaveFileType.SaveJPEG, LoadImg); }