首页 新闻 会员 周边

C++YUV420转RGB

0
悬赏园豆:100 [已解决问题] 解决于 2010-09-04 11:15

已经三天了,一点进展也没有,我以前是.NET的,现在换到Win32平台什么都不懂,遇上了个比较棘手的问题。我想用C#去掉一个C++的方法,传给它的是一段码流,需要转成RGB格式的,但是网上这个方法(http://dev.firnow.com/course/3_program/c++/cppsl/20071119/87075.html)没有返回值,怎么转啊我就奇怪,会的大哥帮帮忙。

     还有就是在C++里面怎么写供C#调用的DLL,谢谢大家了!

本人QQ332547004  有会的帮帮忙,你有什么需要我也会帮你的。

∞Code∞的主页 ∞Code∞ | 初学一级 | 园豆:100
提问于:2010-08-22 15:26
< >
分享
最佳答案
0

C#调用C++写的DLL,这里有个简单的例子。

http://www.cnblogs.com/virusswb/archive/2008/05/30/1210520.html

收获园豆:100
Astar | 高人七级 |园豆:40805 | 2010-08-22 15:48
这个只是声明文件,头文件和源文件怎么写?
∞Code∞ | 园豆:100 (初学一级) | 2010-08-22 15:58
其他回答(1)
0

已经有人问过了,我写了个C#版的,你参考下:

http://space.cnblogs.com/question/16711/

 

C++ dll .h 文件中这样申明:

 

extern "C" __declspec(dllexport) void __stdcall ConvertYUVToRGB(unsigned char *src0,unsigned char *src1,unsigned char *src2,unsigned char *dst_ori,int width, int height);

 

.cpp 文件中这样定义:

 

__declspec(dllexport) void __stdcall ConvertYUVToRGB(unsigned char *src0,unsigned char *src1,unsigned char *src2,unsigned char *dst_ori,int width, int height)
{
// 那些你找的代码。
}

 

 

在 C# 中,这样调用:

 

 

[DllImport("YUVToRGB.dll", CharSet = CharSet.Ansi,CallingConvention = CallingConvention.StdCall)]
public static extern ConvertYUVToRGB(IntPtr src0,IntPtr rc1,IntPtr src2,IntPtr dst_ori,int width, int height);

byte[] src0 = new byte[1024];
byte[] src1 = new byte[1024];
byte[] src2 = new byte[1024];
byte[] dst_ori = new byte[1024];

ConvertYUVToRGB(src0,src1,src2,dst_ori,
640,480);

 

 

Launcher | 园豆:45045 (高人七级) | 2010-08-22 22:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册