![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a very simple (I think) question: How do I convert a unmanaged GDI+ bitmap into a managed GDI+ Image? The code is C++ CLI (.Net 2.0). There is another option, the Bitmap is being generated by calling it's function UnlockBits() that takes a unmanaged Gdiplus::BitmapData structure. Is it easier/safer to convert the unmanaged Gdiplus::BitmapData structure and pass that into a managed Bitmap object's UnlockBits() method? |
#3
| |||
| |||
|
|
There are many ways to Marshal a gdiplus bitmap between managed and unmanaged code. Here are a few methods: 1) You may use GetHBITMAP() to pass a handle to a bitmap. 2) You may use a stream to represent the bitmap. 3) You may use a global memory pointer to a packed DIB(i.e., BITMAPINFOHEADER, ColorTable, bits). 4) You may use a IPictureDisp interface. Choice #1 is the easiest to implement. |
#4
| |||
| |||
|
|
I major concern is not ease, but speed. The unmanaged code is manipulating the data in the unmanaged BitmapData.Scan0 to generate the image for display. When using the LockBits() call, the ImageLockModeUserInputBuf flag is being set. Is it possible to simply cast the unmanaged BitmapData to a managed BitmapData? |
|
On Sep 11, 12:06 pm, "Michael Phillips, Jr." mphillip... (AT) nospam (DOT) jun0.c0m> wrote: There are many ways to Marshal a gdiplus bitmap between managed and unmanaged code. Here are a few methods: 1) You may use GetHBITMAP() to pass a handle to a bitmap. 2) You may use a stream to represent the bitmap. 3) You may use a global memory pointer to a packed DIB(i.e., BITMAPINFOHEADER, ColorTable, bits). 4) You may use a IPictureDisp interface. Choice #1 is the easiest to implement. I major concern is not ease, but speed. The unmanaged code is manipulating the data in the unmanaged BitmapData.Scan0 to generate the image for display. When using the LockBits() call, the ImageLockModeUserInputBuf flag is being set. Is it possible to simply cast the unmanaged BitmapData to a managed BitmapData? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |