Load a bitmap (BMP) from local storage in C#

Bitmap

To load an image from image data stored in the System.Drawing.Bitmap object, use the CreateGdPictureImageFromBitmap method of the GdPictureImaging class. This creates a new GdPicture representation of the image, and it returns the unique image identifier (imageID) of the newly created GdPicture image. This method requires the System.Drawing.Bitmap object as its parameter.

When you no longer need an image resource and the System.Drawing.Bitmap object, release them with the ReleaseGdPictureImage and Dispose methods.

To load an image from local storage, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Load a bitmap image to a bitmap object.
Bitmap bitmapObject = new Bitmap(@"C:\temp\source.bmp");
// Load a GdPicture image from the bitmap object.
int imageID = gdpictureImaging.CreateGdPictureImageFromBitmap(bitmapObject);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
// Release the loaded GdPicture image.
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Release the bitmap object.
bitmapObject.Dispose();