pfff

Untitled

Oct 19th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. object Form10: TForm10
  2. Left = 0
  3. Top = 0
  4. Caption = 'Form10'
  5. ClientHeight = 341
  6. ClientWidth = 446
  7. Color = clBtnFace
  8. Font.Charset = DEFAULT_CHARSET
  9. Font.Color = clWindowText
  10. Font.Height = -11
  11. Font.Name = 'Tahoma'
  12. Font.Style = []
  13. OldCreateOrder = False
  14. PixelsPerInch = 96
  15. TextHeight = 13
  16. object Image1: TImage
  17. Left = 8
  18. Top = 8
  19. Width = 211
  20. Height = 296
  21. end
  22. object Image2: TImage
  23. Left = 225
  24. Top = 8
  25. Width = 211
  26. Height = 296
  27. end
  28. object Button1: TButton
  29. Left = 361
  30. Top = 310
  31. Width = 75
  32. Height = 25
  33. Caption = 'Button1'
  34. TabOrder = 0
  35. OnClick = Button1Click
  36. end
  37. end
  38.  
  39.  
  40.  
  41. unit Unit10;
  42.  
  43. interface
  44.  
  45. uses
  46. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  47. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
  48. Vcl.StdCtrls;
  49.  
  50. type
  51. TForm10 = class(TForm)
  52. Image1: TImage;
  53. Image2: TImage;
  54. Button1: TButton;
  55. procedure Button1Click(Sender: TObject);
  56. private
  57. { Private declarations }
  58. public
  59. { Public declarations }
  60. end;
  61.  
  62. var
  63. Form10: TForm10;
  64.  
  65. implementation
  66.  
  67. {$R *.dfm}
  68.  
  69. function Translate(X, Y: Single): tagXFORM;
  70. begin
  71. Result.eM11 := 1;
  72. Result.eM12 := 0;
  73. Result.eM21 := 0;
  74. Result.eM22 := 1;
  75. Result.eDx := X;
  76. Result.eDy := Y;
  77. end;
  78.  
  79. function Stretch(X, Y: Single): tagXFORM;
  80. begin
  81. Result.eM11 := X;
  82. Result.eM12 := 0;
  83. Result.eM21 := 0;
  84. Result.eM22 := Y;
  85. Result.eDx := 0;
  86. Result.eDy := 0;
  87. end;
  88.  
  89. function R90: tagXFORM; { O= 0,0 }
  90. begin
  91. Result.eM11 := 0;
  92. Result.eM12 := -1;
  93. Result.eM21 := 1;
  94. Result.eM22 := 0;
  95. Result.eDx := 0;
  96. Result.eDy := 0;
  97. end;
  98.  
  99. function CombineTransform(x1, x2: tagXFORM): tagXFORM;
  100. begin
  101. Result.eM11 := x1.eM11 * x2.eM11 + x1.eM12 * x2.eM21;
  102. Result.eM12 := x1.eM11 * x2.eM12 + x1.eM12 * x2.eM22;
  103. Result.eM21 := x1.eM21 * x2.eM11 + x1.eM22 * x2.eM21;
  104. Result.eM22 := x1.eM21 * x2.eM12 + x1.eM22 * x2.eM22;
  105. Result.eDx := x1.eDx * x2.eM11 + x1.eDy * x2.eM21 + x2.eDx;
  106. Result.eDy := x1.eDx * x2.eM12 + x1.eDy * x2.eM22 + x2.eDy;
  107. end;
  108.  
  109. procedure TForm10.Button1Click(Sender: TObject);
  110. var
  111. tr: tagXFORM;
  112. bm: TBitmap;
  113. begin
  114. bm := TBitmap.Create;
  115. bm.Width := Image2.Width;
  116. bm.Height := Image2.Height;
  117. SetGraphicsMode(bm.Canvas.Handle, GM_ADVANCED);
  118.  
  119. { Page 1 }
  120. tr := CombineTransform(R90, Stretch(210 / 297, 210 / 297));
  121. tr := CombineTransform(tr, Translate(0, bm.Height));
  122. SetWorldTransform(bm.Canvas.Handle, tr);
  123. BitBlt(bm.Canvas.Handle, 0, 0, bm.Width, bm.Height, Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
  124.  
  125. { Page 2 }
  126. tr := CombineTransform(R90, Stretch(210 / 297, 210 / 297));
  127. tr := CombineTransform(tr, Translate(0, bm.Height div 2)); { <- the only difference }
  128. SetWorldTransform(bm.Canvas.Handle, tr);
  129. BitBlt(bm.Canvas.Handle, 0, 0, bm.Width, bm.Height, Image1.Picture.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
  130.  
  131. Image2.Picture.Bitmap.Assign(bm);
  132. bm.Free;
  133. end;
  134.  
  135. end.
Advertisement
Add Comment
Please, Sign In to add comment