有高手可幫一下忙 BCD 轉DELPHI 那出問題 |
尚未結案
|
chingrenn
一般會員 發表:10 回覆:13 積分:4 註冊:2003-03-04 發送簡訊給我 |
有高手可幫一下忙 BCD 轉DELPHI 那出問題 //BCD char buffer[256];
int iWidthByte, iHeightDot, x, y;
char *ptr;
char ch; //Open LPT 1
openport("0");
if (isready()==0) {
Application->MessageBox("Printer is not ready", "Error", MB_ICONERROR);
}
else {
iWidthByte = (Image1->Width 7) / 8;
iHeightDot = Image1->Height;
sprintf(buffer, "^Q%d,0,0", (iHeightDot/8) 10);
sendcommand(buffer); sendcommand("^W100");
sendcommand("^P1");
sendcommand("^L");
sprintf(buffer, "Q8,8,%d,%d\n", iWidthByte, iHeightDot);
sendbuf(buffer, strlen(buffer));
for (y = 0; y < iHeightDot; y ) {
ptr = (char *)Image1->Picture->Bitmap->ScanLine[y];
for (x = 0; x < iWidthByte; x ) {
ch = ~*ptr ;
sendbuf(&ch, 1);
}
}
sendcommand("E");
}
closeport(); //DELPHI
var
ptr: PByteArray;
ch : char;
buffer : string;
iWidthByte, iHeightDot, x,y : integer;
begin openport('0'); iWidthByte := (Image1.Width 7) div 8;
edit1.Text := inttostr(iWidthByte);
iHeightDot := Image1.Height;
edit2.Text := inttostr(iHeightDot);
buffer := '';
buffer := '^Q' inttostr((iHeightDot div 8) 10) ',0,0';
sendbuf(pchar(buffer),strlen(Pchar(buffer))); sendcommand('^W100');
sendcommand('^P1');
sendcommand('^L');
//format('Q10,20,%1.1x,%1.1x
buffer := 'Q10,20,' inttostr(iWidthByte) ',' inttostr(iHeightDot) #13;
sendbuf(pchar(buffer), strlen(Pchar(buffer)));
for y := 0 to iHeightDot - 1 do
begin
ptr := Image1.Picture.Bitmap.ScanLine[y];
for x := 0 to iWidthByte - 1 do
ch := ptr^ 1;
sendbuf(pchar(@ch), 1);
end;
sendcommand('E');
closeport();
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |