Visual C++ Developer Center > Visual C++ Forums > Visual C++ General > Image capture using mixed mode c++/cli
Ask a questionAsk a question
 

AnswerImage capture using mixed mode c++/cli

  • Monday, November 02, 2009 4:20 AMAl_S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have an ActiveX control that when called returns a handle to image memory.  In native code use, that memory is locked via GlobalLock to be used as image data in a graphic object.  The return type of the GlobalLock function is casted to a pointer to BITMAPINFOHEADER

    LPBITMAPINFOHEADER  Info = (LPBITMAPINFOHEADER)GlobalLock(Handle);

    This is lifted from an MFC app that perfroms image capture from an USB imaging device which I want to change into a CLR WinForm project without using MFC.

    I am trying to use the variable Info to create Bitmap data for use in a WinForm with LPBITMAPINFOHEADER as  the source of image data

    The disconnect is getting from GDI functions (or GDI+ classes) to the System::Drawing namspace classes.  GDI+ has one mehod that is useful.  The list of constructors has creating a Bitmap from a BITMAPINFO and data array.

    The problem is in the constructor.  I get an error:  error C2061: syntax error : identifier '{ctor}'

    The call is as follows:

    bm = new Gdiplus::Bitmap::Bitmap(bmi, _imgPtr->Bits);

    bm is defined earlier as:
    Gdiplus::Bitmap* bm;


    The alternative is to call explicitly the FromBITMAPINFO method:

    bm = Gdiplus::Bitmap::FromBITMAPINFO(bmi, _imgPtr->Bits);

    This builds but I need to get Bitmap to draw an image to a picturebox on a form.  If I have a returned Bitmap in memory how can I get that into a picture box wihout writing to a file?  The Image and Graphics classes don't look like a solution or maybe I'm missing something.

    Thanks in advance
    Jer 29:11

Answers

All Replies