C++写的函数库DLL,用delphi调用问题,大家都进来看看,解决立马给分,在线等!!!!!!!(200分)

  • 主题发起人 大懒虫!!
  • 开始时间

大懒虫!!

Unregistered / Unconfirmed
GUEST, unregistred user!
dll里的函 数: int __stdcall GetJpegImage(HANDLE hChannelHandle,UCHAR *ImageBuf,<br>ULONG *Size,UINT nQuality)<br><br>如题,在delphi如何声名它,和调用他呢,请给出实际调用例子,解决后马上给分
 
没有人吗,急啊
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3529211<br><br>看看这里吧!
 
[板主肥大道:]典型 大懒虫!!
 
function GetJpegImage(hChannelHandle: THandle; &nbsp;ImageBuf: PChar; &nbsp;var Size: DWORD; &nbsp;nQuality: DWORD): Longint; &nbsp;stdcall; &nbsp;external '???.dll';<br><br><br>我是这样写的,不过在调用时,出错,不知道怎么回事,
 
写法基本上没问题,可能是DLL中有错
 
先用C++调用看有没有错
 
procedure TDvr_Main.GraspVideoPictureBMP(channelNum: integer; FileName: PChar); &nbsp;//抓图<br>var<br>&nbsp; ImgSize : integer;<br>&nbsp; imageBuf : array[1..704 * 576 * 2] of byte;<br>begin<br>&nbsp; if channelNum=-1 then<br>&nbsp; &nbsp; Exit;<br>&nbsp; ImgSize:=704 * 576 * 2;<br>&nbsp; GetOriginalImage(channelNum, @imageBuf, @ImgSize);<br>&nbsp; if (ImgSize = 704 * 576 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 704, 576)<br>&nbsp; else if (ImgSize = 704 * 480 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 704, 480)<br>&nbsp; else if (ImgSize = 352 * 288 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 352, 288)<br>&nbsp; else if (ImgSize = 352 * 240 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf,352, 240)<br>&nbsp; else if (ImgSize = 176 * 144 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 176, 144)<br>&nbsp; else if (ImgSize = 176 * 120 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 176, 120)<br>&nbsp; else if (ImgSize = 704 * 240 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 704, 240)<br>&nbsp; else if (ImgSize = 288 * 224 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 288, 224)<br>&nbsp; else if (ImgSize = 256 * 208 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 256, 208)<br>&nbsp; else if (ImgSize = 528 * 384 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 528, 384)<br>&nbsp; else if (ImgSize = 640 * 480 * 2) then<br>&nbsp; SaveYUVToBmpFile(FileName, @imageBuf, 640, 480);<br>end;<br>procedure TDvr_Main.GraspVideoPictureJPG(channelNum: Longint; FileName: PChar); &nbsp;//JPG抓图<br>var<br>&nbsp; ImgSize : integer;<br>&nbsp; imageBuf : array[1..704 * 576 * 2] of byte; &nbsp; //352 * 288 * 2<br>&nbsp; ret,jpegQuality:integer;<br>&nbsp; pFile: File;<br>begin<br>&nbsp; if channelNum=-1 then<br>&nbsp; &nbsp; Exit;<br>&nbsp; ImgSize:=704*576*2;<br>&nbsp; jpegQuality:=50;<br>&nbsp; ret:=GetJpegImage(channelNum,@imageBuf,@ImgSize,jpegQuality);<br>&nbsp; if(ret=0) &nbsp; then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; AssignFile(pFile,FileName );<br>&nbsp; &nbsp; &nbsp; Rewrite(pFile,imgsize);<br>&nbsp; &nbsp; &nbsp; BlockWrite(pFile, imageBuf,1);<br>&nbsp; &nbsp; &nbsp; CloseFile(pFile);<br>&nbsp; &nbsp; end<br>end;<br><br>procedure TDvr_Main.Dvr_CaptureBMPBtnClick(Sender: TObject);//BMP视频截图<br>var<br>&nbsp; FileName, RootPath, FilePath, NowPath, nowName: string;<br>&nbsp; oCameraInfo : TCameraInfo;<br>&nbsp; ImageBuf : array [ 0..704*576*2-1 ] of char;<br>&nbsp; ImageSize : ulong;<br>begin<br>&nbsp; if inttostr(sel) &lt;&gt; '' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; FilePath := FormatDateTime('YYYYMMDD', Date) + '/'+inttostr(sel+1)+'路'+'/'; &nbsp;//文件目录<br>&nbsp; &nbsp; &nbsp; &nbsp; FileName := FormatDateTime('hhmmnnss', now); &nbsp; &nbsp; //文件名<br>&nbsp; &nbsp; &nbsp; &nbsp; RootPath := 'd:/截图目录/';<br>&nbsp; &nbsp; &nbsp; &nbsp; NowPath := RootPath + FilePath ;<br>&nbsp; &nbsp; &nbsp; &nbsp; ForceDirectories(NowPath);<br>&nbsp; &nbsp; &nbsp; &nbsp; NowName := NowPath+FileName+'.BMP';<br>&nbsp; &nbsp; &nbsp; &nbsp; GraspVideoPictureBMP(sel, Pchar(NowName));<br>&nbsp; &nbsp; &nbsp; //GraspVideoPictureJPG(sel, Pchar(NowName));<br>&nbsp; &nbsp; &nbsp; &nbsp; StatusBar1.Panels[3].Text := inttostr(sel+1)+'路' + '图片已截取';<br>&nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage('图片截取过程失败!');;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;
 
procedure TDvr_Main.Dvr_CaptureJPGBtnClick(Sender: TObject); //JPG截图<br>var<br>&nbsp; FileName, RootPath, FilePath, NowPath, nowName: string;<br>&nbsp; oCameraInfo : TCameraInfo;<br>&nbsp; ImageBuf : array [ 0..704*576*2-1 ] of char;<br>&nbsp; ImageSize : ulong;<br>begin<br>&nbsp; if inttostr(sel) &lt;&gt; '' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; FilePath := FormatDateTime('YYYYMMDD', Date) + '/'+inttostr(sel+1)+'路'+'/'; &nbsp;//文件目录<br>&nbsp; &nbsp; &nbsp; &nbsp; FileName := FormatDateTime('hhmmnnss', now); &nbsp; &nbsp; //文件名<br>&nbsp; &nbsp; &nbsp; &nbsp; RootPath := 'd:/截图目录/';<br>&nbsp; &nbsp; &nbsp; &nbsp; NowPath := RootPath + FilePath ;<br>&nbsp; &nbsp; &nbsp; &nbsp; ForceDirectories(NowPath);<br>&nbsp; &nbsp; &nbsp; &nbsp; NowName := NowPath+FileName+'.Jpg';<br>&nbsp; &nbsp; &nbsp; &nbsp; //GraspVideoPictureBMP(sel, Pchar(NowName));<br>&nbsp; &nbsp; &nbsp; &nbsp; GraspVideoPictureJPG(sel, Pchar(NowName));<br>&nbsp; &nbsp; &nbsp; &nbsp; StatusBar1.Panels[3].Text := inttostr(sel+1)+'路' + '图片已截取';<br>&nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage('图片截取过程失败!');;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>end;
 
function GetJpegImage(hChannelHandle:integer;ImageBuf:pChar;Size:pLongWord;nQuality:integer):Integer;stdcall; &nbsp;<br>function &nbsp;GetJpegImage;external 'ds40xxsdk.dll' name 'GetJpegImage';
 
对不,请看一下。
 
要看看你的c++中的dll函数?可能问题在这里
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
812
import
I
顶部