MFC CreateDIB and C#

  • Thread starter Thread starter Mark G
  • Start date Start date
M

Mark G

Hi, with MFC I use the following to display and save a 2
pixels per byte raw image;

m_hDIBTemplate = CreateDIB(unpackedimage, 96, 96);
CreateDIBPalette(m_hDIBTemplate, &Palette);
hPal = (HPALETTE) Palette.m_hObject;
PaintDIB(TheDC.m_hDC, &frame, m_hDIBTemplate,
&templateDIBrect, &Palette);
stat = SaveDIB(m_hDIBTemplate, myfile);


How can I accomplish the same thing using C# and webforms?

Thanks
 
Hi Mark,

Reference System.Drawing.dll from your Web app.
Create a Bitmap instance having required size and pixel format by using an
appropriate constructor.
Create a Graphics instance with its static FromImage (or FromBitmap, don't
remember exactly)
Do the necessary drawing and save the bitmap with its Save method

P.S. The names of the methods might be inexact, but the general idea is like
this. One more important note is to ensure the Web app has enough
permissions to create files on disk (and to do so in a particular folder).
 
Hi, Thanks for your reply but I stil can't get anywhere.
What I have in C# is a byte array of a raw image that
comes from a hardware dvice. In MFC all I did was to call
createDIB(ImageArray,96,96) and I could essentially view
or save the image. How can this be done in c#? Again,
thanks.

-----Original Message-----
Hi Mark,

Reference System.Drawing.dll from your Web app.
Create a Bitmap instance having required size and pixel format by using an
appropriate constructor.
Create a Graphics instance with its static FromImage (or FromBitmap, don't
remember exactly)
Do the necessary drawing and save the bitmap with its Save method

P.S. The names of the methods might be inexact, but the general idea is like
this. One more important note is to ensure the Web app has enough
permissions to create files on disk (and to do so in a particular folder).

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Mark G said:
Hi, with MFC I use the following to display and save a 2
pixels per byte raw image;

m_hDIBTemplate = CreateDIB(unpackedimage, 96, 96);
CreateDIBPalette(m_hDIBTemplate, &Palette);
hPal = (HPALETTE) Palette.m_hObject;
PaintDIB(TheDC.m_hDC, &frame, m_hDIBTemplate,
&templateDIBrect, &Palette);
stat = SaveDIB(m_hDIBTemplate, myfile);


How can I accomplish the same thing using C# and webforms?

Thanks

.
 
Mark said:
Hi, Thanks for your reply but I stil can't get anywhere.
What I have in C# is a byte array of a raw image that
comes from a hardware dvice. In MFC all I did was to call
createDIB(ImageArray,96,96) and I could essentially view
or save the image. How can this be done in c#? Again,
thanks.

You want something like:

IntPtr data = /*data from hardware*/;
Bitmap bmp = new Bitmap( 96, 96, 96*4, PixelFormat.Format32bppRgb, data );

However, don't quote me as I'm reading straight from the docs without
trying it.
 

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

Back
Top