我正在A3打印机画布上画画。
是否可以复制画布的部分和 在画布的另一部分画出旋转(180度)?
谢谢!
答案 0 :(得分:7)
就像Sertac已经评论过的那样,使用SetWorldTransform
:
procedure TForm1.Button1Click(Sender: TObject);
var
XForm: TXForm;
begin
if PrintDialog1.Execute then
with Printer do
begin
BeginDoc;
SetGraphicsMode(Canvas.Handle, GM_ADVANCED);
PrintTo(Canvas);
XForm.eM11 := Cos(DegToRad(180));
XForm.eM12 := Sin(DegToRad(180));
XForm.eM21 := -Sin(DegToRad(180));
XForm.eM22 := Cos(DegToRad(180));
XForm.eDx := PageWidth;
XForm.eDy := PageHeight;
SetWorldTransform(Canvas.Handle, XForm);
PrintTo(Canvas);
EndDoc;
end;
end;
procedure TForm1.PrintTo(ACanvas: TCanvas);
begin
with ACanvas do
begin
Font.Size := 180;
TextOut(0, 0, 'Test text');
Pen.Width := 40;
MoveTo(0, 0);
LineTo(3000, 3000);
end;
end;
答案 1 :(得分:0)
您可以将重复部分绘制到临时位图,并在旋转后在打印机画布上绘制两次该位图。例如,可以使用PlgBlt:
完成轮换procedure RotateBitmap180(Source, Dest: TBitmap);
var
Points: array[0..2] of TPoint;
begin
if (Source <> nil) and (Dest <> nil) then
with Source, Canvas do
begin
Dest.Width := Width;
Dest.Height := Height;
Points[0].X := Width - 1;
Points[0].Y := Height - 1;
Points[1].X := -1;
Points[1].Y := Height - 1;
Points[2].X := Width - 1;
Points[2].Y := -1;
PlgBlt(Dest.Canvas.Handle, Points, Handle, 0, 0, Width, Height, 0, 0, 0);
Dest.Modified := True;
end;
end;
注意:有更高效的旋转例程,因为PlgBlt不仅可以旋转,还可以进行缩放。但是这个短暂的工作就完成了。