Load a bitmap (BMP) for conversion from a stream in C#

Bitmap

To load and convert a bitmap image from a stream object to a different file type, use the LoadFromStream method from the GdPictureDocumentConverter class. This method requires the following parameters:

  • Stream — The stream object of a bitmap image.
  • DocumentFormat — The file format represented as a member of the DocumentFormat enumeration.

To load and convert a bitmap image from a stream object, use the following code:

// Create a stream object from a bitmap image file.
using Stream streamFile = new FileStream(@"C:\temp\source.bmp", FileMode.Open);
// Create a new `gdpictureDocumentConverter` object.
using GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter();
// Specify the file format.
GdPicture14.DocumentFormat format = GdPicture14.DocumentFormat.DocumentFormatBMP;
// Load the stream object to the `gdpictureDocumentConverter` object.
gdpictureDocumentConverter.LoadFromStream(streamFile, format);
gdpictureDocumentConverter.SaveAsPDF(@"C:\temp\output.pdf");