unit Unit_GDIPLUSDEMO;
///
/// extract all pages from an *.tif file using GDI PLus
///
///
///
///
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, GDIPAPI, GDIPOBJ, GDIPUTIL,
Vcl.StdCtrls;
type
TForm1 =
class(TForm)
edt_imagefilename: TEdit;
btn_loadfilename: TButton;
dlgOpenimagefile: TOpenDialog;
btn_splitt_tif_file: TButton;
procedure btn_loadfilenameClick(Sender: TObject);
procedure btn_splitt_tif_fileClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn_loadfilenameClick(Sender: TObject);
begin
if dlgOpenimagefile.Execute
then
begin
edt_imagefilename.Text := dlgOpenimagefile.FileName;
end;
end;
procedure TForm1.btn_splitt_tif_fileClick(Sender: TObject);
var
encoderClsid: TGUID;
encoderParameters: TEncoderParameters;
quality: ULONG;
stat: TStatus;
MulitFrameImage: TGPImage;
PageIndex : Integer;
NewFilename :
String;
begin
/// Get an tif image from the disk.
MulitFrameImage := TGPImage.Create(edt_imagefilename.Text);
/// Get the CLSID of the JPEG, TIFF ... encoder.
GetEncoderClsid('
image/tif', encoderClsid);
for PageIndex:= 1
to 80
do
begin
/// Display and save the first page (index 0).
MulitFrameImage.SelectActiveFrame(encoderClsid, PageIndex);
// graphics.DrawImage(&multi, 10, 10);
NewFilename := '
e:\tiffsplit\' + ExtractFileName(edt_imagefilename.Text) + IntToStr(PageIndex) + '
.tif';
MulitFrameImage.Save( WideString(NewFilename), encoderClsid,
nil );
end;
end;
end.