This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/load-a-file/imaging/from-stream-bitmap.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Load a bitmap (BMP) from stream in C# .NET | Nutrient .NET SDK
Bitmap

To load a BMP image from a Stream, use the CreateGdPictureImageFromStream method from the GdPictureImaging class.

This method returns a non-zero GdPicture image identifier (imageID) on success. If it fails, it returns 0 — use GetStat() to view the failure reason.

You can also use the overload that specifies format explicitly:

  • CreateGdPictureImageFromStream(Stream, DocumentFormat ImageFormat)

For BMP streams, pass DocumentFormat.DocumentFormatBMP.

Remember to release image resources with the ReleaseGdPictureImage method.

To load a BMP image from a stream, use the following code:

using GdPicture14;
using System;
using System.IO;
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a stream object from a BMP file.
using Stream streamImage = new FileStream(@"C:\temp\source.bmp", FileMode.Open, FileAccess.Read);
// Create a GdPicture image from the stream object.
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(
streamImage,
DocumentFormat.DocumentFormatBMP);
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromStream failed: {gdpictureImaging.GetStat()}");
return;
}
GdPictureStatus status = gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveAsPNG failed: {status}");
}
gdpictureImaging.ReleaseGdPictureImage(imageID);