Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting 32bpp bitmaps to byte arrays

24 views
Skip to first unread message

Genzzry

unread,
Sep 1, 2011, 3:52:26 PM9/1/11
to
Hi, I have been trying to convert a 32bpp bitmap to a byte array and
came accross the following example using Bitmap.LockBits:
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx#Y1072

As Im coding in vb.net, I used that example and noticed the line "'
This code is specific to a bitmap with 24 bits per pixels." This
means that I can give the routine a 24bpp bmp and it will work but I
need to work with 32bpp bitmaps.

If you give the demo code on that page a 32bpp bmp, it crashes at the
line "System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0,
bytes)" with the error "Attempted to read or write protected memory."
meaning that its probably going to the wrong place or read to far?

Does anyone know how to convert 32bpp bmp's to a byte array and could
maybe tell me how to make the code with with 32bpp bitmaps instead of
the 24bpp ones? (or why its crashing? ...or even if libs already
exist for this?)

Thanks for reading this post, even if your unable to help :)

0 new messages