如何从非托管C ++ lib函数中获取C#中的位图,该函数返回DIB win32处理程序 [英] How can I get bitmap in C# from unmanaged C++ lib function which return DIB win32 handler
本文介绍了如何从非托管C ++ lib函数中获取C#中的位图,该函数返回DIB win32处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Developers,我将在C#FROM C ++ DIB Win32处理程序中获取IMAGE。
使用管理包装技术我包装所有其他函数并从无法管理的LIB文件中获取所有其他值..这次我想包装这个函数
Hello Developers, i am going to get IMAGE in C# FROM a c++ DIB Win32 Handler.
Using manage wrapping techniques i wrap all other function and get all other value from unmanageable LIB File.. this time i wanna Wrap this Function
HGLOBAL XRaySensorGetDIB(void);
和返回位图或字节数组(图像)并在我的C#项目中获取输出位图或字节数组图像....
提前感谢
我尝试了什么:
这里是我的c ++ / CLI管理包装的一些代码
and Return Bitmap or byte Array (Image) and get Output Bitmap or byte Array Image in my C# Project....
thanks in advance
What I have tried:
here is some code of my c++/CLI Managed Wrapping
HBITMAP managedDllWrapper::ManageFunctionWrapper::SaveImageWrapper()
{
HGLOBAL m_hDib;
int retval = XRaySensorIsImageAvailable();
if ( 0 < retval )
{
if (m_hDib ) ::GlobalFree(m_hDib);
m_hDib = XRaySensorGetDIB();
}
HBITMAP bmi=new HBITMAP();
bmi=&m_hDib;
return bmi;
}
推荐答案
这可能会有所帮助: DIB到System.Bitmap [ ^ ]
This might help: DIB to System.Bitmap[^]
很遗憾地告诉您,您缺少有关位图的必要知识。这是 Microsoft文档中的一个很好的起点。请深入了解不同的CreateBitmap和BitBlt函数以了解HBITMAP。它是系统对象的句柄,需要很多关注。 ;-)
我的想法和知识将通过提供C#中的数据并用C ++填充它来实现另一种方式。
烹饪书
1.要求大小
2.在C#中分配位图并传输句柄或缓冲区
3.将位图复制到位图句柄或得到用C ++填充的位
提示:使用搜索框查看不同的样本
I am sorry to tell you, that you are missing the needed knowledge about bitmaps. Here is a good starting point in the Microsoft documentation. Please take a deeper look at the different CreateBitmap and BitBlt function to understand the HBITMAP. It is a handle to a system object and needs a lot of care. ;-)
My idea and knowledge would go the other way by providing the data from C# and fill it in C++.
cook book
1. ask for the size
2. allocate in C# a bitmap and transfer the handle or the buffer
3. copy the bitmap into the bitmap handle or get the bits filled in C++
Tip: use the search box and look at different samples
这篇关于如何从非托管C ++ lib函数中获取C#中的位图,该函数返回DIB win32处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文