Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 i'm 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

  • *Gurus*
Posted
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, you'll need to pin the array using a GCHandle before calling this method.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...