Problem with GetDIBits / SetBitmapBits / GetDIBits in C#

V

vvsarun

Hi,

i am having problem in using GetDIBits / SetDIBits using C#. I was
succeeded in using GetBitmapBits but SetBitmapBits is not working.
Then i tried using GetDIBits and SetDIBits, which are always returning
0 bytes read. Code...

byte[] bitmapbits = new byte[153*113];
BITMAPINFO lpbmi = new BITMAPINFO() ;
lpbmi.bmiHeader.biSize = 153 * 113;
lpbmi.bmiHeader.biHeight = -113;
lpbmi.bmiHeader.biWidth = 153;
lpbmi.bmiHeader.biPlanes = 1;
lpbmi.bmiHeader.biBitCount = 16;
lpbmi.bmiHeader.biCompression = BI_RGB;
lpbmi.bmiHeader.biSizeImage = 0;
pictureBox1.Image = bmp;
Graphics gp = pictureBox1.CreateGraphics();
int numRead = GetDIBits(gp.GetHdc(),bmp.GetHbitmap(), 0,
(uint)pictureBox1.Height, bitmapbits, ref lpbmi, DIB_RGB_COLORS);
gp.ReleaseHdc();

Please help me in using above functions with C#.

At present i am using GetPixel function, but it is time consuming.


Thanks in advance
Arun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top