bwells Posted August 14, 2003 Posted August 14, 2003 I see I can use the BitmapData associated with a Bitmap to modify the data of a bitmap. I have constructed a Bitmap of the correct size, and I have an array of byte data which is organized correctly for the Bitmap I want to create. Since I am working in C++, if I use the scan0 returned from the BitmapData, can I use memcpy to transfer my image data into the bitmap? The scan0 field of the BitmapData returns an IntPtr. Can I use memcpy with an IntPtr to copy my unmanaged data into the bitmap? thanks Bryan Quote
OnErr0r Posted August 14, 2003 Posted August 14, 2003 If you would use GdipCreateBitmapFromScan0 or the bitmap constructor that wraps it: public Bitmap ( System.Int32 width , System.Int32 height , System.Int32 stride , System.Drawing.Imaging.PixelFormat format , System.IntPtr scan0 ) you could just have Scan0 point to the data and create the bitmap from that data all at once, no copying. After the bitmap has been created, you can LockBits and use Scan0 to alter it's pixels, then UnlockBits when done. 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.