Load a Vector Image (SVG) from a Byte Array in C#

To load an image from a byte array, use the CreateGdPictureImageFromByteArray 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 accepts the following parameters:

  • Data — The image data stored in a byte array.

  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

Warning

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 a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from an image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.jpg");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
Using  gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create a byte array from an image.
    Dim byteaArray = File.ReadAllBytes("C:\temp\source.jpg")
    ' Create a GdPicture image from the byte array.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

To load a bitmap image from a byte array, use the CreateGdPictureImageFromByteArray 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 accepts the following parameters:

  • Data — The image data stored in a byte array.

  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

Warning

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

To load a bitmap image from a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from a bitmap image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.bmp");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
Using  gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create a byte array from a bitmap image.
    Dim byteaArray = File.ReadAllBytes("C:\temp\source.bmp")
    ' Create a GdPicture image from the byte array.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

To load an SVG image from a byte array, use the CreateGdPictureImageFromByteArray 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 accepts the following parameters:

  • Data — The image data stored in a byte array.

  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

Warning

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 SVG image from a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from an SVG image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.svg");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
Using  gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create a byte array from an SVG image.
    Dim byteaArray = File.ReadAllBytes("C:\temp\source.svg")
    ' Create a GdPicture image from the byte array.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

To load a DICOM image from a byte array, use the CreateGdPictureImageFromByteArray 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 accepts the following parameters:

  • Data — The image data stored in a byte array.

  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

Warning

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

To load a DICOM image from a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from a DICOM image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.dcm");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
Using  gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create a byte array from a DICOM image.
    Dim byteaArray = File.ReadAllBytes("C:\temp\source.dcm")
    ' Create a GdPicture image from the byte array.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

To load a TIFF image from a byte array, use the CreateGdPictureImageFromByteArray 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 accepts the following parameters:

  • Data — The image data stored in a byte array.

  • ImageFormat — Optional: A member of the DocumentFormat enumeration that specifies the image format.

Warning

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

To load a TIFF image from a byte array, use the following code:

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from a TIFF image.
byte[] byteaArray = File.ReadAllBytes(@"C:\temp\source.tif");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
Using  gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create a byte array from a TIFF image.
    Dim byteaArray = File.ReadAllBytes("C:\temp\source.tif")
    ' Create a GdPicture image from the byte array.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromByteArray(byteaArray)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using