Bitmaps and com interop
-
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?
-
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?
-
arcticbrew wrote:
Has anyone successfully passed bitmaps back and forth between managed and unmanaged code?
Yes
led mike
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.
-
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.
-
how are you drawing to the bitmap in unmanaged code? Don't you need a Device Context?