Save images in C#
To Bitmap
To save a GdPicture image to a bitmap image, use the SaveAsBMP
method of the GdPictureImaging
class. It uses the following parameters:
imageID
— The ID of the GdPicture image.FilePath
— The file path where you want to save the image. If the specified file already exists, the method overwrites it.UseRLE
— A Boolean value that specifies if the bitmap pixels are compressed with the RLE compression scheme. It’s only available for bitmaps with 8 bits per pixel.
When you no longer need an image resource, release it with the ReleaseGdPictureImage
method.
The following example saves a previously loaded JPG image to bitmap format:
using GdPictureImaging gdPictureImaging = new GdPictureImaging();// Create a GdPicture image from a JPG file.int imageID = gdPictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");// Save the GdPicture image as a bitmap file.gdPictureImaging.SaveAsBMP(imageID, @"C:\temp\output.bmp");gdPictureImaging.ReleaseGdPictureImage(imageID);
Using gdPictureImaging As GdPictureImaging = New GdPictureImaging() ' Create a GdPicture image from a JPG file. Dim imageID As Integer = gdPictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg") ' Save the GdPicture image as a bitmap file. gdPictureImaging.SaveAsBMP(imageID, "C:\temp\output.bmp") gdPictureImaging.ReleaseGdPictureImage(imageID)End Using