byte array to bitmap

MrVideo

New member
Joined
Mar 8, 2003
Messages
2
Hi,

i have an array of bytes that includes the raw RGB data of an image. I also know the width, height and Bitdepth of the original image. Now i want to create a bitmap from that information.

I found this constructor of System.Drawing.Bitmap

Public Sub New( _
ByVal width As Integer, _
ByVal height As Integer, _
ByVal stride As Integer, _
ByVal format As PixelFormat, _
ByVal scan0 As IntPtr _
)

but im not sure how to get an IntPtr from my byte array data. Is it possible to use this constructor to create my bitmap from raw RGB data?


Marc
 
It looks like it is possible, you might find that Marshal.UnsafeAddrOfPinnedArrayElement is the function you need to call to get the address of the first element in the byte array. As the help for this method says, youll need to pin the array using a GCHandle before calling this method.
 

Similar threads

Back
Top