📄 rm_e_gif.pas
字号:
unit RM_e_gif;
interface
{$I RM.INC}
{$IFDEF RXGIF}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, RM_Class, RM_E_Graphic, RxGIF;
type
{ TRMGIFExport }
TRMGIFExport = 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;
{ TRMGIFExportForm }
TRMGIFExportForm = class(TForm)
gbGIF: TGroupBox;
btnOK: TButton;
btnCancel: TButton;
chkMonochrome: TCheckBox;
Label1: TLabel;
Label2: TLabel;
edScaleX: TEdit;
Label3: TLabel;
edScaleY: TEdit;
Label4: TLabel;
cmbPixelFormat: TComboBox;
procedure FormCreate(Sender: TObject);
private
procedure Localize;
protected
public
end;
{$ENDIF}
implementation
{$IFDEF RXGIF}
uses RM_CmpReg, RM_Const, RM_Utils;
{$R *.DFM}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMGIFExport}
constructor TRMGIFExport.Create(AOwner: TComponent);
begin
inherited;
FMonochrome := False;
FFileExtension := 'gif';
RMRegisterExportFilter(Self, RMLoadStr(SGIFFile), '*.gif');
end;
function TRMGIFExport.ShowModal: Word;
begin
if not ShowDialog then
Result := mrOk
else
begin
with TRMGIFExportForm.Create(nil) do
begin
try
edScaleX.Text := FloatToStr(Self.ScaleX);
edScaleY.Text := FloatToStr(Self.ScaleY);
chkMonochrome.Checked := Self.Monochrome;
Result := ShowModal;
if Result = mrOK then
begin
Self.ScaleX := StrToFloat(edScaleX.Text);
Self.ScaleY := StrToFloat(edScaleY.Text);
Self.Monochrome := chkMonochrome.Checked;
end;
finally
Free;
end;
end;
end;
end;
procedure TRMGIFExport.OnEndPage;
var
GIF: TGraphic;
BMP: TBitmap;
begin
GIF := TGIFImage.Create;
try
BMP := TBitmap.Create;
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));
GIF.Assign(BMP);
GIF.SaveToStream(Stream);
BMP.Free;
finally
GIF.Free;
end;
inherited OnEndPage;
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMGIFExportForm}
procedure TRMGIFExportForm.Localize;
begin
Font.Name := RMLoadStr(SRMDefaultFontName);
Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
Font.Charset := StrToInt(RMLoadStr(SCharset));
RMSetStrProp(Self, 'Caption', rmRes + 1790);
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 TRMGIFExportForm.FormCreate(Sender: TObject);
begin
Localize;
end;
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -