Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Bitmaps and com interop

Bitmaps and com interop

Scheduled Pinned Locked Moved ATL / WTL / STL
comgraphicscsharpc++performance
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arcticbrew
    wrote on last edited by
    #1

    I am working in the compact framework. I have an ATL object that needs to draw on a bitmap. I need to pass the bitmap to a C# program and display it. We have tried creating the bitmap in C# with GDI methods then used the APIs for CompatibleDCs, selectobject, getHdc, etc and passed the DC to the ATL object. On returning it from the ATL object I get ExceptionHandling errors relating to memory when I try to get a bitmap I can use in managed code. We have been able to pass the DeviceContext and draw directly on it but I want to retrieve a bitmap that I can cache as a member variable in my class. Has anyone successfully passed bitmaps back and forth between managed and unmanaged code?

    L 1 Reply Last reply
    0
    • A arcticbrew

      I am working in the compact framework. I have an ATL object that needs to draw on a bitmap. I need to pass the bitmap to a C# program and display it. We have tried creating the bitmap in C# with GDI methods then used the APIs for CompatibleDCs, selectobject, getHdc, etc and passed the DC to the ATL object. On returning it from the ATL object I get ExceptionHandling errors relating to memory when I try to get a bitmap I can use in managed code. We have been able to pass the DeviceContext and draw directly on it but I want to retrieve a bitmap that I can cache as a member variable in my class. Has anyone successfully passed bitmaps back and forth between managed and unmanaged code?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      arcticbrew wrote:

      Has anyone successfully passed bitmaps back and forth between managed and unmanaged code?

      Yes

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        arcticbrew wrote:

        Has anyone successfully passed bitmaps back and forth between managed and unmanaged code?

        Yes

        led mike

        A Offline
        A Offline
        arcticbrew
        wrote on last edited by
        #3

        Hi Mike thanks for responding. Would you describe the method you used. I tried creating a bitmap from the device context of the screen, passing the Device Context and hBitmmap to unmanaged code, drawing on the bitmap in unmanaged code and passing back to managed code. But when I try to draw in managed code using GDI I get a memory exception.

        L 1 Reply Last reply
        0
        • A arcticbrew

          Hi Mike thanks for responding. Would you describe the method you used. I tried creating a bitmap from the device context of the screen, passing the Device Context and hBitmmap to unmanaged code, drawing on the bitmap in unmanaged code and passing back to managed code. But when I try to draw in managed code using GDI I get a memory exception.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          I passed only HBITMAP

          led mike

          A 1 Reply Last reply
          0
          • L led mike

            I passed only HBITMAP

            led mike

            A Offline
            A Offline
            arcticbrew
            wrote on last edited by
            #5

            how are you drawing to the bitmap in unmanaged code? Don't you need a Device Context?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups