- #1
Jimmy Snyder
- 1,127
- 21
This is for a project I am working on using windows forms and c#. I have some data in an array of bytes. It is a b&w image of ones and zeros, 8 pixels to a byte. 32 pixels by 32 pixels. I have many such arrays and would like to display them in a picturebox in various colors. In otherwords, one of the 32x32 images would be red, another green, a third blue, etc, with perhaps 200 such images on the screen at once. One way would be to draw them pixel by pixel into the component, but this seems slow. Is there some way I could just send an array of bytes to some method that would magically turn the entire array into an image? How would you go about it? I don't need a detailed description, just a rough roadmap would suffice.
GetDIBits looks like it might work, but when I try to use it, the visual C# compiler says "The name GetDIBits does not exist in the current context"
Code examples for GetHBitmap look like this:
IntPtr hBitmap = bm.GetHbitmap(Color.Blue);
// Do something with hBitmap.
DeleteObject(hBitmap);
It's the Do something part that I need help with.
GetDIBits looks like it might work, but when I try to use it, the visual C# compiler says "The name GetDIBits does not exist in the current context"
Code examples for GetHBitmap look like this:
IntPtr hBitmap = bm.GetHbitmap(Color.Blue);
// Do something with hBitmap.
DeleteObject(hBitmap);
It's the Do something part that I need help with.