Q
qianxianen
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家帮着看一下代码有什末问题,就是在执行Ret_value:=CXCMD_ImageOut(piSlot, piID, @pbyPlaneK, 1036*664, 0, 0);时返回值不正确,非常大的数,应返回0。但是我把1036*664改为1036时就可以成功。该函数定义Function CXCMD_ImageOut(piSlot:Integer;piID:Integer;pbyPlaneByte;iLength:Integer;iColor:Integer;iBuffer:Integer):Integer;far;stdcall;external 'PCP08CT.DLL'; //输出图像另外我把PByteArray定义改为PByteArray = ^TByteArray; TByteArray = array[0..32767] of Byte; //TByteArray = array[0..1000000] of Byte;//源码procedure TForm1.Button_PrintClick(Sender: TObject);var piSlot,piID:Integer; x,y,result:Integer; pbyPlaneY,pbyPlaneM,pbyPlaneC,pbyPlaneK,pbyPlaneUV:array of Byte;begin setlength(pbyPlaneY,1036*664); setlength(pbyPlaneM,1036*664); setlength(pbyPlaneC,1036*664); setlength(pbyPlaneK,1036*664); setlength(pbyPlaneUV,1036*664); for i:=0 to 1036*664-1 do begin pbyPlaneY:=0; pbyPlaneM:=0; pbyPlaneC:=0; pbyPlaneK:=0; pbyPlaneUV:=0; end; photo.Picture.LoadFromFile('E:/33.bmp'); photo.Refresh; for x:=2 to photo.Picture.Width do begin for y:=1 to photo.Picture.Height do begin result:= photo.Canvas.Pixels[x,y]; pbyPlaneY[y*1036+x]:=255-GetBValue(result); pbyPlaneM[y*1036+x]:=255-GetGValue(result); pbyPlaneC[y*1036+x]:=255-GetRValue(result); pbyPlaneK[y*1036+x]:=0; end; end; piSlot:=0; piID:=0; Ret_value:=CXCMD_ScanPrinter(piSlot,piID); //if Ret_value=0 then // begin // showmessage('连接成功'+inttostr(piSlot)+inttostr(piID)); //end; {Ret_value:=CXCMD_CheckIfConnected(piSlot,piID); if Ret_value=0 then begin showmessage('机器已连接成功'); end; } Ret_value:=CXCMD_ImageOut(piSlot, piID, @pbyPlaneK, 1036*664, 0, 0); //Ret_value:=CXCMD_ImageOut(piSlot, piID, @pbyPlaneY, 1036*664, 3, 0); //Ret_value:=CXCMD_ImageOut(piSlot, piID, @pbyPlaneM, 1036*664, 2, 0); //Ret_value:=CXCMD_ImageOut(piSlot, piID, @pbyPlaneC, 1036*664, 1, 0); if Ret_value=0 then begin Ret_value:=CXCMD_Print(piSlot, piID, 3, 0, 0); sleep(2000); if Ret_value=0 then begin Ret_value:=CXCMD_LoadCard(piSlot, piID, 0, 0, 0, 0); sleep(2000); Ret_value:=CXCMD_RetransferAndEject(piSlot, piID, 0); sleep(10000); if Ret_value=0 then begin Showmessage('打印成功'); end; end; end else begin Showmessage('数据下载失败!'); end;end;