另开一帖 C++ C#高手进

smaworm 2009-05-27 11:55:57
函 数: int __stdcall GetJpegImage(HANDLE hChannelHandle,UCHAR *ImageBuf,
ULONG *Size,UINT nQuality)
参 数: HANDLE hChannelHandle;通道句柄
UCHAR *ImageBuf;JPEG图像指针
ULONG *Size;JPEG图像尺寸,函数调用前是 ImageBuf 的大小,调用后
图像所占用的字节数
UINT nQuality;JPEG图像质量,取值范围 1-100,取值 100时质量最好

此函数在C#中应该怎么调用呢 对方提供了动态库。
注意:我想知道在C#中如何调用,而不是仅仅写出如何定义这个函数 高手回答 谢谢了先
...全文
91 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
langlang0810 2009-06-10
  • 打赏
  • 举报
回复
我用了这个代码,能成功保存jpg文件,但是有个问题,就是一般只能保存一次,第二次保存的时候图片不能显示,这个是为什么呢?文件大小跟可显示的大小是一样的,
smaworm 2009-05-27
  • 打赏
  • 举报
回复
非常感谢 结贴给分
可以去http://topic.csdn.net/u/20090527/10/a90ce355-522a-4895-bf13-e6ac8e5fad69.html?seed=797610865 留个名 同样给分
gomoku 2009-05-27
  • 打赏
  • 举报
回复
[DllImport("DS40xxSDK.dll")]
public static extern int GetJpegImage(IntPtr hChannelHandle, byte[] ImageBuf, ref int Size, int nQuality);


void Test()
{
byte[] buffer = new byte[2 * 1000 * 1000];
int length = buffer.Length;
GetJpegImage( ..., buffer, ref length, 100);
using (System.IO.FileStream fs = new System.IO.FileStream("c:\\temp\\b.jpg", System.IO.FileMode.Create))
{
fs.Write(buffer, 0, length);
}
}
smaworm 2009-05-27
  • 打赏
  • 举报
回复
我是这么写的
[DllImport("DS40xxSDK.dll", EntryPoint = "GetJpegImage")]
public static extern int GetJpegImage(IntPtr hChannelHandle, ref Image ImageBuf, ref ulong Size, int nQuality);

Image image1 = new Bitmap("a.JPG");
ulong size = 0;
int a = SysJianKong.GetJpegImage(intptr[0], ref image1, ref size, 80);
image1.Save("b.JPG");

问题是当调用GetJpegImage 后 image1变成了Null

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧