图像打印问题(50分)

  • 主题发起人 主题发起人 fzj
  • 开始时间 开始时间
F

fzj

Unregistered / Unconfirmed
GUEST, unregistred user!
这样定义为什么编译不通过,告诉我原因,在线等待

TYPE
TRect=record
case integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
 
怎么没人响应呀,我在线等待,急!!!!!!!!!!!!!!!!!!
 
应该是:
TRect = packed record
case Integer of
0: (Left, Top, Right, Bottom: Longint);
1: (TopLeft, BottomRight: TPoint);
end;
这个结构DELPHI已经定义,你为何要重新定义?编译不能通过,也许是因为你重复定义所致。

 
to 冰凌
type
TRect = packed record
case integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
这样定义也不行呀,错误消息expected end but type found
您说delphi有这个结构,我怎么引用呀,我没找到呀,我在打印照片的时候为了调整尺寸想用一下,但就是不能用,告诉我一下,谢谢了!
 
这个定义在WINDOWS单元,你可以直接使用:
var
Rect:TRect;
 
to 冰凌
procedure Tsjlr.BitBtn1Click(Sender: TObject);
var
Rect:TRect;
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
begin
if printdialog1.execute then begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//将放大的图形向打印机输出
enddoc;
end;
end;
end;

还有一个问题,怎么引入printer变量
 
Delphi中有一个Printers单元,在Uses中加入,然后:
var
Printer:TPrinter;
 
to 冰凌
var
Rect:TRect;
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
printer:TPrinter;
begin
if printdialog1.execute then begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2) and (temwd printter.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//将放大的图形向打印机输出
enddoc;
end;
end;
end;

while (temhi printer.pageheight div 2) and (temwd printter.pagewidth div 2) do 这句话有问题吗?我怎么编译也不通过,显示[Error] usjlr.pas(748): ')' expected but identifier 'printer' found这样的错误信息
 
哈哈,这个错了:
temwd printter.pagewidth div 2
应为:
temwd printer.pagewidth div 2
多了上个t
 
var
Rect:TRect;
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
printer:TPrinter;
begin
if printdialog1.execute then begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//将放大的图形向打印机输出
enddoc;
end;
end;
end;

我修改过了呀,还是同样的问题呀,帮帮我哟,谢谢了
 
to 冰凌
procedure Tsjlr.BitBtn1Click(Sender: TObject);
var
Rect:TRect;
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
printer:TPrinter;
begin
if printdialog1.execute then begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//将放大的图形向打印机输出
enddoc;
end;
end;
end;
我修改过了,还是同样的问题,是怎么回事,帮帮我呀,谢谢了
 
while (temhi printer.pageheight div 2) and (temwd printter.pagewidth div 2) do
这句有问题
printer.pageheight 和printter.pagewidth 没有赋值;
你应该将打印对话里得到的值赋给它们。
 
to 冰凌
while (temhi 800 div 2) and (temwd 600 div 2) do
这样我先赋给他一个常量可以吗
 
to 冰凌
我把while (temhi 800 div 2) and (temwd 600 div 2) do 写成这样赋常量也不行,我要把一张照片按我的要求尺寸输出,这样写,整个代码有问题吗?
procedure Tsjlr.BitBtn1Click(Sender: TObject);
var
Rect:TRect;
strect:Trect; //定义打印输出矩形框的大小
temhi,temwd:integer;
printer:TPrinter;
begin
if printdialog1.execute then begin
temhi:=image1.picture.height;
temwd:=image1.picture.width;
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
with strect do //定义图形在页面上的中心位置输出
begin
left:=(printer.pagewidth -temwd) div 2;
top:=(printer.pageheight-temhi) div 2;
right:=left+temwd;
bottom:=top+temhi;
end;
with printer do
begin
begindoc;
canvas.stretchdraw(strect,image1.picture.graphic);
//将放大的图形向打印机输出
enddoc;
end;
end;
end;
 
这段话什么意思?不懂。
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
//将图形放大到打印页面的1/2大小
begin
temhi:=temhi+temhi;
temwd:=temwd+temwd;
end;
按你的说法,为什么不是:
temhi:=printer.pageheight div 2;
temwd:=printer.pagewidth div 2;

 
while (temhi printer.pageheight div 2) and (temwd printer.pagewidth div 2) do
这句语法错误,temhi和 printer.pageheight div 2中间没有操作符,temwd 和printer.pagewidth div 2也一样。
 
to Xelloss
我也不怎么清楚,抄不明白,我觉得
temhi:=temhi+temhi;
temwd:=temwd+temwd;
好象就是有问题
 
to 冰凌
我从网上看到的这段代码,那按上下文的意思,中间的操作符应该是什么呢
 
用小于号试试。
 
后退
顶部