How to C#: Save Image Using XImage.Raster
Overview for How to Use XImage.Raster to save raster image in C# .NET Programming Project
RasterEdge XImage.Raster has provided four ways to save raster image object that are save to file, stream, byte array and bitmap.
The site Advanced Save Options has explained how to use the save options. When saving RasterImage object, if the parameter SaveOptions was not set, XImage.Raster SDK will save the image according to the default save option settings.
c# tiff library,
best asp.net pdf library,
asp.net pdf editor,
vb.net print form to pdf,
vb.net read pdf to text,
c# wpf preview pdf.
That is, if you don't have any special needs, or don't know how to preset the save options, you can save image with the default save options whether it is PNG/BMP such a single frame image or GIF/TIFF such a multi frame image.
Related .net document control helps:
asp.net edit pdf image using c#:
ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net edit pdf text using c#:
ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net view tiff images: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
c# asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net pdf document viewer c#: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm...
asp.net sharepoint document viewer open source: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
c# asp.net powerpoint viewer: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
Steps to Save Image
Load an image with RasterImage object.
Create an image processor with ImageProcess object.
Call the Save/SaveToStream/SaveToBytes method of ImageProcess object to complete the task flopping image.
Save the modified image to an image file on the disk.
In order to acheive the work, please refer to the following steps.
convert pdf to image in asp.net c#,
c# split pdf itextsharp,
c# redact pdf,
itextsharp jpg to pdf vb.net,
c# parse pdf itextsharp,
c# convert txt to pdf,
pdf free library c#.
Install XImage.Raster in C# Project
Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;
RasterEdge.Imaging.Basic.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XImage.Raster.dll
Use corresponding namespaces;
using RasterEdge.XImage.Raster;
Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:
If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.
If using x86, the platform target should be x86.
asp.net show image from folder,
pdf editor asp.net,
excel viewer asp.net c#,
mvc display pdf in partial view,
preview pdf in asp.net mvc,
open word file in asp.net c#,
how to view pdf file in asp.net using c#.
Save Image to file Using C#
You can save image to file using the codes as follows.
When save image to file, it will be save into the format get from the suffix of the filename. If the format is not supported, the image will be saved as .png file.
Sample Code(save image with default option)
RasterImage img = new RasterImage(@"input.jpeg");
img.Save(@"output.PNG");
|
Sample Code(save image with save option)
RasterImage img = new RasterImage(@"input.jpeg");
SaveOption option = new SaveOption();
//if SveOption is set, the ImageFormat must be set too.
option.ImageFormat = ImageFormat.PNG;
img.Save(@"output.jpeg", option);
|
Save Image to Stream Using C#
With the XImage.Raster SDK, you can save image to a memory or file stream. While, you can save a single frame image or multi frame image in the same way. You can save image to stream as follows.
Sample Code(save image to stream according to the specified format)
RasterImage img = new RasterImage(@"input.jpeg");
Stream stream = new MemoryStream();
img.SaveToStream(stream, ImageFormat.PNG);
|
Sample Code(save image to stream with save option)
RasterImage img = new RasterImage(@"input.jpeg");
SaveOption option = new SaveOption();
option.ImageFormat = ImageFormat.PNG;
option.Png.Filter = PNGFilter.PAETH;
Stream stream = new MemoryStream();
img.SaveToStream(stream, option);
|
Save Image to Bitmap or DIB Using C#
With the XImage.Raster SDK, you can save image to System.Drawing.Bitmap or DIB data.
Sample Code(save image to bitmap according to the specified format)
RasterImage img = new RasterImage(@"input.jpeg");
//Save to Bitmap
Bitmap bmp = img.ToBitmap();
//Save to DIB
IntPtr intPtr = img.ToHbitmap();
|
Save Image to byte array Using C#
With the XImage.Raster SDK, you can save image to a byte array, you can save a single frame image or multi frame image in the same way. You can save image to a byte array.
Sample Code(save image to byte array according to the specified format)
RasterImage img = new RasterImage(@"input.jpeg");
Byte[] result = img.SaveToBytes(ImageFormat.PNG);
|
Sample Code(save image to byte array with save option)
RasterImage img = new RasterImage(@"input.jpeg");
SaveOption option = new SaveOption();
option.ImageFormat = ImageFormat.PNG;
option.Png.Filter = PNGFilter.PAETH;
byte[] result = img.SaveToBytes(option);
|