Thread: Passing .Net Bitmap to C++ Dll

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    7

    Passing .Net Bitmap to C++ Dll

    Ok, I have a .Net application but i want to do all the image processing within a C++ dll for speed. What would be the best way to achieve this? How would I pass the .Net Bitmap to the dll, I mean what would the C++ Dll parameter be? Also does anyone know any good C++ Image Processing resources? I guess I'm just a little loss on how this would work. Thanks in advance all

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    C++ has no idea what a .NET bitmap is so you can't just pass it like that.
    Consider creating a C++.NET project as you can use both raw C++ and .NET features, and interoperate using marshalling.
    Interop can be expensive so unless your image computations are really heavy you might decrease performance.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    7
    What if I was to pass the Bitmap as an RGB int array? because the program processes images constantly.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Bitmaps consist of more than just an RGB array (IIRC 24bit colour depth bitmaps are BGR).

    You may be able to use the Bitmap.GetHbitmap() and pass the HBITMAP to the C++ DLL.


    What image processing do you want to do?

    OCR or something with edge detection, stretches etc?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    7
    The Image Processing functions in which I currently have Include Invert, Cropping, Scalling, Brighten, Sharpen, Blur, gray scale, ect.... and at times OCR will be needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. C++ .NET - "inconsistent dll linkage" - What's that?
    By BrianK in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2004, 10:16 AM
  4. Loading bitmap in dll
    By Mithoric in forum Windows Programming
    Replies: 2
    Last Post: 12-22-2003, 01:53 PM
  5. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 03:13 AM