Access GDI+ Image pointer from unmanaged C++ dll...
-
I have a C++ dll that opens an image file using GDI+ and gets a thumbnail of the opened image using GetThumbnailImage. I would like the C++ DLL to be able to return a pointer to the Image and then have a custom C# control of mine display it. Does anyone know how I can share this image information between the two languages? (I know I can use C#'s GDI image functions to create the thumbnail also, but the C++ version is much faster).
-
I have a C++ dll that opens an image file using GDI+ and gets a thumbnail of the opened image using GetThumbnailImage. I would like the C++ DLL to be able to return a pointer to the Image and then have a custom C# control of mine display it. Does anyone know how I can share this image information between the two languages? (I know I can use C#'s GDI image functions to create the thumbnail also, but the C++ version is much faster).
You could have the C++ dll return the handle to the image using the GDI+ Bitmap.GetHBitmap(). Your C# control could then get an IntPtr containing the handle to the bitmap and use Image.FromHBitmap() to get the image object back. Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons