import
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
program MultiBitmap;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
mbMainForm in 'mbMainForm.pas' {MainForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
[Stats]
|
||||
EditorSecs=82
|
||||
DesignerSecs=5
|
||||
InspectorSecs=1
|
||||
CompileSecs=850
|
||||
OtherSecs=5
|
||||
StartTime=20.12.2004 11:40:22
|
||||
RealKeys=0
|
||||
EffectiveKeys=0
|
||||
DebugSecs=19
|
||||
@@ -0,0 +1,89 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 203
|
||||
Top = 192
|
||||
Width = 696
|
||||
Height = 480
|
||||
Caption = 'MultiBitmap Demo'
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Shell Dlg 2'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
OnPaint = FormPaint
|
||||
OnResize = FormResize
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object ToolBar: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 688
|
||||
Height = 25
|
||||
AutoSize = True
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 33
|
||||
Caption = 'ToolBar'
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
Flat = True
|
||||
Indent = 3
|
||||
ShowCaptions = True
|
||||
TabOrder = 0
|
||||
object tbLoad: TToolButton
|
||||
Left = 3
|
||||
Top = 0
|
||||
Caption = 'Load'
|
||||
ImageIndex = 0
|
||||
OnClick = tbLoadClick
|
||||
end
|
||||
object ToolButton1: TToolButton
|
||||
Left = 36
|
||||
Top = 0
|
||||
Width = 8
|
||||
Caption = 'ToolButton1'
|
||||
ImageIndex = 1
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object tbClose: TToolButton
|
||||
Left = 44
|
||||
Top = 0
|
||||
Caption = 'Close'
|
||||
ImageIndex = 1
|
||||
OnClick = tbCloseClick
|
||||
end
|
||||
object ToolButton2: TToolButton
|
||||
Left = 77
|
||||
Top = 0
|
||||
Width = 8
|
||||
Caption = 'ToolButton2'
|
||||
ImageIndex = 2
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 85
|
||||
Top = 0
|
||||
Width = 36
|
||||
Height = 21
|
||||
Caption = 'Pages: '
|
||||
Layout = tlCenter
|
||||
end
|
||||
object cbPages: TComboBox
|
||||
Left = 121
|
||||
Top = 0
|
||||
Width = 60
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
DropDownCount = 15
|
||||
ItemHeight = 13
|
||||
TabOrder = 0
|
||||
OnChange = cbPagesChange
|
||||
end
|
||||
end
|
||||
object OD: TOpenDialog
|
||||
Filter = 'TIFF multibitmap (*.tiff, *.tif)|*.tiff; *.tif|ICO|*.ico'
|
||||
Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing]
|
||||
Title = 'Open multibitmap..'
|
||||
Left = 64
|
||||
Top = 96
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,150 @@
|
||||
unit mbMainForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, ComCtrls, ToolWin, StdCtrls, FreeBitmap;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
ToolBar: TToolBar;
|
||||
tbLoad: TToolButton;
|
||||
ToolButton1: TToolButton;
|
||||
tbClose: TToolButton;
|
||||
ToolButton2: TToolButton;
|
||||
cbPages: TComboBox;
|
||||
Label1: TLabel;
|
||||
OD: TOpenDialog;
|
||||
procedure tbLoadClick(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure tbCloseClick(Sender: TObject);
|
||||
procedure cbPagesChange(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
private
|
||||
FMultiBitmap: TFreeMultiBitmap;
|
||||
FPage: TFreeWinBitmap;
|
||||
|
||||
procedure PageBitmapChangeHandler(Sender: TObject);
|
||||
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure OpenMultiBitmap(const FileName: string);
|
||||
procedure CloseMultiBitmap;
|
||||
procedure OpenPage(Number: Integer);
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainForm.CloseMultiBitmap;
|
||||
begin
|
||||
if FPage.IsValid then
|
||||
FMultiBitmap.UnlockPage(Fpage, False);
|
||||
FMultiBitmap.Close;
|
||||
cbPages.Clear;
|
||||
end;
|
||||
|
||||
constructor TMainForm.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
FMultiBitmap := TFreeMultiBitmap.Create;
|
||||
FPage := TFreeWinBitmap.Create;
|
||||
FPage.OnChange := PageBitmapChangeHandler;
|
||||
end;
|
||||
|
||||
destructor TMainForm.Destroy;
|
||||
begin
|
||||
if FMultiBitmap.IsValid then
|
||||
CloseMultiBitmap;
|
||||
FMultiBitmap.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TMainForm.OpenMultiBitmap(const FileName: string);
|
||||
var
|
||||
I, Cnt: Integer;
|
||||
begin
|
||||
if FMultiBitmap.IsValid then CloseMultiBitmap;
|
||||
|
||||
FMultiBitmap.Open(FileName, False, True);
|
||||
|
||||
Cnt := FMultiBitmap.GetPageCount;
|
||||
cbPages.OnChange := nil;
|
||||
cbPages.Clear;
|
||||
for I := 0 to Cnt - 1 do
|
||||
cbPages.Items.Add(IntToStr(I));
|
||||
cbPages.OnChange := cbPagesChange;
|
||||
end;
|
||||
|
||||
procedure TMainForm.OpenPage(Number: Integer);
|
||||
begin
|
||||
if not FMultiBitmap.IsValid then Exit;
|
||||
|
||||
if FPage.IsValid then
|
||||
FMultiBitmap.UnlockPage(FPage, False);
|
||||
|
||||
FMultiBitmap.LockPage(Number, FPage);
|
||||
end;
|
||||
|
||||
procedure TMainForm.PageBitmapChangeHandler(Sender: TObject);
|
||||
begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TMainForm.tbLoadClick(Sender: TObject);
|
||||
begin
|
||||
if OD.Execute then
|
||||
begin
|
||||
try
|
||||
OpenMultiBitmap(OD.FileName);
|
||||
except
|
||||
raise Exception.CreateFmt('Can not load file %s', [OD.FileName]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.WMEraseBkgnd(var Message: TWMEraseBkgnd);
|
||||
begin
|
||||
Message.Result := 1;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormPaint(Sender: TObject);
|
||||
begin
|
||||
if not FPage.IsValid then
|
||||
begin
|
||||
Canvas.Brush.Color := clBtnFace;
|
||||
Canvas.FillRect(ClientRect);
|
||||
end
|
||||
else
|
||||
FPage.Draw(Canvas.Handle, ClientRect);
|
||||
end;
|
||||
|
||||
procedure TMainForm.tbCloseClick(Sender: TObject);
|
||||
begin
|
||||
if FMultiBitmap.IsValid then
|
||||
CloseMultiBitmap;
|
||||
end;
|
||||
|
||||
procedure TMainForm.cbPagesChange(Sender: TObject);
|
||||
var
|
||||
Page: Integer;
|
||||
begin
|
||||
Page := StrToInt(cbPages.Text);
|
||||
OpenPage(Page);
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormResize(Sender: TObject);
|
||||
begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user