Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何从.net位图获取本机GDI位图_C++_.net_Gdi+_Gdi - Fatal编程技术网

C++ 如何从.net位图获取本机GDI位图

C++ 如何从.net位图获取本机GDI位图,c++,.net,gdi+,gdi,C++,.net,Gdi+,Gdi,我想在使用Pinvoke技术的本机库中使用.net位图,本机函数有以下原型 int cropImage( bool aBlocking,Gdiplus::Bitmap *aInputImage, ) 我喝了以下的平伏酒 public extern int cropImage( bool blocking , Intptr bitmap ) 我这样称呼它 System.Drawing.Bitmap b = new Syste.Drawing.Bitmap("Amour.jpg"); cro

我想在使用Pinvoke技术的本机库中使用.net位图,本机函数有以下原型

int cropImage(  bool aBlocking,Gdiplus::Bitmap *aInputImage, )
我喝了以下的平伏酒

public extern int cropImage( bool blocking , Intptr bitmap ) 
我这样称呼它

System.Drawing.Bitmap b = new Syste.Drawing.Bitmap("Amour.jpg");
cropImage(true,b.getHitmap());

但它不起作用,你有什么建议

我建议,克服这个问题的最佳方法是使用本机库,它接受HBitmap,然后使用CBitmap::fromHandle函数,然后调用您试图与之通信的api

> GdiPux::位图是C++类,它在<代码> <代码> Windows SDK头文件中声明。它是一个包装类,用于使不友好的低级GDI+C接口更易于使用。位图是“强>不<强”,它直接取代了C++类,它也是一个围绕低级GDI+API的包装类,但用C语言编写。它与C++包装器完全没有关系。使用位图中的HbM映像,GeTHEBMAP()也不起作用,这是句柄,不是C++对象。

不能直接从C++调用这个函数,pJoNKE不支持创建C++对象。您需要用C++/CLI语言编写ref类包装器。既支持编写托管代码又支持不调用PNECKE的本机C++代码的语言。您可以根据需要

#包括
,以便创建Gdiplus::Bitmap对象。另一种方法是使用C++来创建一个DLL,它有两个导出函数,一个创建GdiPux::位图,另一个则破坏它。这将允许您使用pinvoke,将参数声明为IntPtr