C# Imaging Library
How to save, export images in C#?
How to Use XImage.Raster to save, export 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 page Advanced Saving 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.
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.
How to read, save TIFF, BMP, PNG raster images using C#?
Quickstart: Save, export images into an image file in C#
With just one line of simple C# code
RasterImage.Save(), you can save, export an image from
RasterImage object in C# applicatoin.
- Install "XImage.Raster" & "RasterEdge.Core" through NuGet Package Manager in Visual Studio
- Copy and run the following C# code snippet.
RasterImage anImage = new RasterImage("raster-sample-image.png");
anImage.Save("C:\\output\\raster-image-saved.png");
- Deploy to test on your running environment
Save, export image to memory object using C#
Here we will learn how to save and export image to C# memory object. So that we can further process the image content, such as embed them to PDF, Word documents or store them to the database in your C# ASP.NET web and desktop applications.
Export to Stream object
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.
RasterImage img = new RasterImage("raster-sample-image.png");
Stream stream = new MemoryStream();
img.SaveToStream(stream, ImageFormat.PNG);
Export to Bitmap or HBitmap object
Using 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("sample-image.png");
Bitmap bmp = img.ToBitmap();
IntPtr intPtr = img.ToHbitmap();
Export to byte array
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.
- Call method
SaveToBytes with image format provided.
RasterImage img = new RasterImage("sample-image.png");
Byte[] result = img.SaveToBytes(ImageFormat.PNG);