用C#做爱国者H5相机的二次开发,由于Demo只有VC、VB的,我想将相机捕捉到的画面,动态同步到picturebox1中,但调试出现如下问题,这个PInvoke是什么错,或者C#有其他实现方法吗?
库文件声明:
[DllImport("gdi32.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern int SetStretchBltMode(
IntPtr hdc,
int nStretchMode);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern long StretchDIBits(
HDC hdc,
long x,
long y,
long dx,
long dy,
long SrcX,
long SrcY,
long wSrcWidth,
long wSrcHeight,
object lpBits,
BITMAPINFOHEADER lpBitsInfo,
long wUsage,
long dwRop);
运行报错:
VB6.0怎么转成VB.net ,需要安装第三方的插件吗?
将指定的CallingConvention和CharSet去掉也不行
这是VB的代码:
Private Declare Function StretchDIBits Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, lpBits As Any, lpBitsInfo As BITMAPINFO, ByVal wUsage As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC& Lib "user32" (ByVal hwnd As Long)
Private Declare Function ReleaseDC& Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long)
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Private Sub Timer1_Timer()
Dim bRet As Boolean
Dim dibret As Long
Dim bmi As BITMAPINFO
bmi.bmiHeader.biSize = 40
bmi.bmiHeader.biWidth = video_w
bmi.bmiHeader.biHeight = video_h
bmi.bmiHeader.biPlanes = 1
bmi.bmiHeader.biBitCount = 24
bmi.bmiHeader.biCompression = 0
bmi.bmiHeader.biSizeImage = 0
bmi.bmiHeader.biXPelsPerMeter = 0
bmi.bmiHeader.biYPelsPerMeter = 0
bmi.bmiHeader.biClrUsed = 0
bmi.bmiHeader.biClrImportant = 0
bRet = KZPreviewOneVideoFrameRGB(Video_RGB(0))
Dim mydc As Long
mydc = GetDC(Picture1.hwnd)
SetStretchBltMode mydc, 4
StretchDIBits mydc, 639, 0, -640, 480, 0, 0, video_w, video_h, Video_RGB(0), bmi, 0, &HCC0020
ReleaseDC Picture1.hwnd, mydc
Sleep 3
End Sub
有VB源代码的话,转换成C#应该不难呀,能贴出VB的相应代码看看吗?
先转VB.NET,然后编译,C#就直接能引用了。
非常赞同!
将指定的CallingConvention和CharSet去掉试试