📄 rm_e_bmp.pas
字号:
unit RM_e_bmp;
interface
{$I RM.INC}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, RM_Class, RM_E_Graphic;
type
{ TRMBMPExport }
TRMBMPExport = class(TRMGraphicExport)
private
FMonochrome: Boolean;
FPixelFormat: TPixelFormat;
public
constructor Create(AOwner: TComponent); override;
function ShowModal: Word; override;
procedure OnEndPage; override;
published
property Monochrome: Boolean read FMonochrome write FMonochrome default False;
property PixelFormat: TPixelFormat read FPixelFormat write FPixelFormat default pf24bit;
end;
{ TRMBMPExportForm }
TRMBMPExportForm = class(TForm)
gbBMP: TGroupBox;
chkMonochrome: TCheckBox;
btnOK: TButton;
btnCancel: TButton;
Label1: TLabel;
Label2: TLabel;
edScaleX: TEdit;
Label3: TLabel;
edScaleY: TEdit;
Label4: TLabel;
cmbPixelFormat: TComboBox;
procedure FormCreate(Sender: TObject);
private
protected
procedure Localize;
public
end;
implementation
{$R *.DFM}
uses RM_CmpReg, RM_Const, RM_Utils;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMBMPExport}
constructor TRMBMPExport.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FMonochrome := False;
FPixelFormat := pf24bit;
FFileExtension := 'bmp';
RMRegisterExportFilter(Self, RMLoadStr(SBMPFile), '*.bmp');
end;
function TRMBMPExport.ShowModal: Word;
begin
if not ShowDialog then
Result := mrOk
else
begin
with TRMBMPExportForm.Create(nil) do
begin
try
edScaleX.Text := FloatToStr(Self.ScaleX);
edScaleY.Text := FloatToStr(Self.ScaleY);
chkMonochrome.Checked := Self.Monochrome;
cmbPixelFormat.ItemIndex := Integer(Self.PixelFormat);
Result := ShowModal;
if Result = mrOK then
begin
Self.ScaleX := StrToFloat(edScaleX.Text);
Self.ScaleY := StrToFloat(edScaleY.Text);
Self.Monochrome := chkMonochrome.Checked;
Self.PixelFormat := TPixelFormat(cmbPixelFormat.ItemIndex);
end;
finally
Free;
end;
end;
end;
end;
procedure TRMBMPExport.OnEndPage;
var
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.Width := FPageWidth;
Bmp.Height := FPageHeight;
Bmp.Monochrome := FMonochrome;
Bmp.PixelFormat := FPixelFormat;
DrawbkPicture(Bmp.Canvas);
CurReport.EMFPages.Draw(FPageNo, Bmp.Canvas, Rect(0, 0, FPageWidth, FPageHeight));
Bmp.SaveToStream(Stream);
finally
Bmp.Free;
end;
inherited OnEndPage;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMBMPExportForm}
procedure TRMBMPExportForm.Localize;
begin
Font.Name := RMLoadStr(SRMDefaultFontName);
Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
Font.Charset := StrToInt(RMLoadStr(SCharset));
RMSetStrProp(Self, 'Caption', rmRes + 1807);
RMSetStrProp(chkMonochrome, 'Caption', rmRes + 1808);
RMSetStrProp(Label1, 'Caption', rmRes + 1806);
RMSetStrProp(Label4, 'Caption', rmRes + 1788);
btnOK.Caption := RMLoadStr(SOk);
btnCancel.Caption := RMLoadStr(SCancel);
end;
procedure TRMBMPExportForm.FormCreate(Sender: TObject);
begin
Localize;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -