I'm having a problem with copying an array of structures as a byte array. The structures are simple RGB structs.
public struct RGBColor { byte r; byte g; byte b; }
Then I have an array of RGBColor[]
that represents a scanline that I want to copy to a Bitmap
after I've called LockBits()
. It will only allow an array of byte[]
to be copied using Marshal.Copy()
.
If I understand correctly (keep in mind I DO NOT UNDERSTAND), I need to marshal the RGBColor[]
array to a byte array, copy the data to that new byte[]
array, and then copy that array to the bitmap. It seems like there's an unnecessary copying operation occuring and I have an intermediate byte[]
array just serving as a middle man.
Isn't there any way I can cast RGBColor[]
to byte[]
so I can just copy it directly to the locked bitmap?