Develop and Download Open Source Software

Browse Subversion Repository

Contents of /printbmp.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Mon Nov 7 12:03:00 2011 UTC (12 years, 4 months ago) by shiraishikazuo
File MIME type: text/x-pascal
File size: 2905 byte(s)


1 unit printbmp;
2 {$IFDEF FPC}
3 {$MODE DELPHI}{$H+}
4 {$ENDIF}
5 interface
6 uses
7 SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 ExtCtrls, StdCtrls, Buttons, LResources ;
9
10 type
11 TPrintBMPDialog = class(TForm)
12 BitBtn1: TBitBtn;
13 BitBtn2: TBitBtn;
14 Panel1: TPanel;
15 PrinterButton: TButton;
16 RadioGroup1: TRadioGroup;
17 procedure PrinterButtonClick(Sender: TObject);
18 procedure FormCreate(Sender: TObject);
19 procedure FormDestroy(Sender: TObject);
20 private
21 { Private 宣言 }
22 public
23 { Public 宣言 }
24 end;
25
26 //var PrintBMPDialog: TPrintBMPDialog;
27 procedure PrintBitMap(BitMap:TBitMap);
28
29 implementation
30 uses Types, Printers, IniFiles, PrintersDlgs,
31 base, sconsts, myutils;
32 {$R *.lfm}
33
34
35 procedure TPrintBMPDialog.PrinterButtonClick(Sender: TObject);
36 begin
37 //NotAvailableMessage;
38 //printer.ExecuteSetup
39
40 with TPrinterSetupDialog.create(self) do
41 begin
42 Execute;
43 free;
44 end;
45
46 end;
47
48
49 procedure PrintBitMap(BitMap:TBitMap);
50 var
51 GRect,Grect1: TRect;
52 BMPRatio,PRTRatio: Single;
53 begin
54 with TPrintBMPDialog.create(nil) do
55 begin
56 if showModal=mrOk then
57 {todo 1 printer}
58
59 with printer do
60 begin
61 if RadioGroup1.ItemIndex=0 then
62 begin
63 BeginDoc;
64 Canvas.Draw(0,0, BitMap);
65 EndDoc;
66 end
67 else
68 begin
69 with GRect do
70 begin
71 left:=0;
72 right:=pagewidth ; //-2* Margins.cx;
73 top:=0;
74 bottom:=pageheight ;//-2* margins.cy;
75 end;
76 GRect1:=Grect;
77 with GRect do
78 PRTRatio :=(Bottom-Top)/(Right-Left);
79 BMPRatio := BitMap.Height / BitMap.Width;
80 if PRTRatio>=BMPRatio then
81 begin
82 GRect.Bottom := GRect.Top+trunc((GRect.Right-Grect.Left) * BMPRatio);
83 end
84 else
85 begin
86 GRect.Right:=GRect.Left + trunc((GRect.Bottom-GRect.Top)/BMPRatio);
87 end;
88
89 BeginDoc;
90 Canvas.StretchDraw(GRect, BitMap);
91 EndDoc;
92 end;
93 end;
94
95 free;
96 end;
97 end;
98
99 procedure TPrintBMPDialog.FormCreate(Sender: TObject);
100 begin
101 (*
102 with TMyIniFile.create('PrintBMP') do
103 begin
104 RadioGroup1.ItemIndex:=ReadInteger('EnLarge',RadioGroup1.ItemIndex);
105 free
106 end ;
107 *)
108 end;
109
110 procedure TPrintBMPDialog.FormDestroy(Sender: TObject);
111 begin
112 (*
113 with TMyIniFile.create('PrintBMP') do
114 begin
115 WriteInteger('EnLarge',RadioGroup1.ItemIndex);
116 free
117 end ;
118 *)
119 end;
120
121 Initialization
122
123 end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26