Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Form10: TForm10
- Left = 0
- Top = 0
- Caption = 'Form10'
- ClientHeight = 341
- ClientWidth = 446
- Color = clBtnFace
- Font.Charset = DEFAULT_CHARSET
- Font.Color = clWindowText
- Font.Height = -11
- Font.Name = 'Tahoma'
- Font.Style = []
- OldCreateOrder = False
- PixelsPerInch = 96
- TextHeight = 13
- object Image1: TImage
- Left = 8
- Top = 8
- Width = 211
- Height = 296
- end
- object Image2: TImage
- Left = 225
- Top = 8
- Width = 211
- Height = 296
- end
- object Button1: TButton
- Left = 361
- Top = 310
- Width = 75
- Height = 25
- Caption = 'Button1'
- TabOrder = 0
- OnClick = Button1Click
- end
- end
- unit Unit10;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
- Vcl.StdCtrls;
- type
- TForm10 = class(TForm)
- Image1: TImage;
- Image2: TImage;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form10: TForm10;
- implementation
- {$R *.dfm}
- function Translate(X, Y: Single): tagXFORM;
- begin
- Result.eM11 := 1;
- Result.eM12 := 0;
- Result.eM21 := 0;
- Result.eM22 := 1;
- Result.eDx := X;
- Result.eDy := Y;
- end;
- function Stretch(X, Y: Single): tagXFORM;
- begin
- Result.eM11 := X;
- Result.eM12 := 0;
- Result.eM21 := 0;
- Result.eM22 := Y;
- Result.eDx := 0;
- Result.eDy := 0;
- end;
- function R90: tagXFORM; { O= 0,0 }
- begin
- Result.eM11 := 0;
- Result.eM12 := -1;
- Result.eM21 := 1;
- Result.eM22 := 0;
- Result.eDx := 0;
- Result.eDy := 0;
- end;
- function CombineTransform(x1, x2: tagXFORM): tagXFORM;
- begin
- Result.eM11 := x1.eM11 * x2.eM11 + x1.eM12 * x2.eM21;
- Result.eM12 := x1.eM11 * x2.eM12 + x1.eM12 * x2.eM22;
- Result.eM21 := x1.eM21 * x2.eM11 + x1.eM22 * x2.eM21;
- Result.eM22 := x1.eM21 * x2.eM12 + x1.eM22 * x2.eM22;
- Result.eDx := x1.eDx * x2.eM11 + x1.eDy * x2.eM21 + x2.eDx;
- Result.eDy := x1.eDx * x2.eM12 + x1.eDy * x2.eM22 + x2.eDy;
- end;
- procedure TForm10.Button1Click(Sender: TObject);
- var
- tr: tagXFORM;
- bm: TBitmap;
- begin
- bm := TBitmap.Create;
- bm.Width := Image2.Width;
- bm.Height := Image2.Height;
- SetGraphicsMode(bm.Canvas.Handle, GM_ADVANCED);
- { Page 1 }
- tr := CombineTransform(R90, Stretch(210 / 297, 210 / 297));
- tr := CombineTransform(tr, Translate(0, bm.Height));
- SetWorldTransform(bm.Canvas.Handle, tr);
- BitBlt(bm.Canvas.Handle, 0, 0, bm.Width, bm.Height, Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
- { Page 2 }
- tr := CombineTransform(R90, Stretch(210 / 297, 210 / 297));
- tr := CombineTransform(tr, Translate(0, bm.Height div 2)); { <- the only difference }
- SetWorldTransform(bm.Canvas.Handle, tr);
- BitBlt(bm.Canvas.Handle, 0, 0, bm.Width, bm.Height, Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
- Image2.Picture.Bitmap.Assign(bm);
- bm.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment