You are here: GdPicture.NET > Documentation > Classes > GdPictureImaging Class > GdPictureImaging Methods > Creating, Loading & Closing GdPicture Image > CreateGdPictureImageFromByteArray Method
logo.gif
ContentsIndexHome
PreviousUpNext
GdPictureImaging.CreateGdPictureImageFromByteArray Method

Creates a new GdPicture Image from an image file stored within an array of bytes.

C#
public int CreateGdPictureImageFromByteArray(
    ref Byte arBytes
);
Visual Basic
Public Function CreateGdPictureImageFromByteArray(
    ByRef arBytes() As Byte
) As Integer
Parameters
Parameters 
Description 
arBytes 
Array which contains image file data.  
Returns

0: The image could not created. Use the GetStat() function to determine the reason this function failed. 

Non-zero: GdPicture Image Identifier. The created image.

If success, set the created image as a GdPicture image. 

Supported formats are RAW, PICT, BMP, DIB, RLE, ICO, EMF, WMF, GIF, ANIMATED GIF, JPEG, JPG, JPE, JFIF, PNG, TIFF, MULTIPAGE TIFF, PNM, PPM, PBM, PGM, PFM, RPPM, RPGM, RPBM, PCX, XPM, XBM, WBMP, TGA, SGI, Sun RAS, PSD, MNG, Kodak PhotoCD files, KOALA files, JP2, J2K, JNG, JBIG, IFF, HDR, Raw Fax G3, EXR, DDS and Dr. Halo files. 

Note for multipage images (TIFF and GIF): 

By default, the class loads multipage images (GIF and TIFF) as read only. 

If you want to open multipage images as read & write, you should the TiffOpenMultiPageForWrite() function for tiff files or the GifOpenMultiFrameForWrite() function for gif files.

How to create an image from an array of bytes

Dim oFile As System.IO.FileInfo
oFile = New System.IO.FileInfo("myimage.gif")
 
Dim oFileStream As System.IO.FileStream = oFile.OpenRead()
Dim lBytes As Integer = CInt(oFileStream.Length)
 
If (lBytes > 0) Then
   Dim fileData(lBytes - 1) As Byte
   Dim ImageID As Integer
 
   oFileStream.Read(fileData, 0, lBytes)
   oFileStream.Close()
   ImageID = oGdPictureImaging.CreateGdPictureImageFromByteArray(fileData)
End If
What do you think about this topic? Send feedback!
Copyright (c) 2009-2011 www.gdpicture.com. All rights reserved.