MrVideo Posted March 8, 2003 Posted March 8, 2003 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 Quote
*Gurus* divil Posted March 8, 2003 *Gurus* Posted March 8, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
MrVideo Posted March 8, 2003 Author Posted March 8, 2003 Success! That really works, thank you very much! Marc Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.