Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.136 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: einzel bmps aus einer tif Datei auslesen

  Alt 6. Jul 2012, 12:26
anbei mein DEMO code mit GDI PLus .... leider is jedes einzelnen *.tif Bild nur schwarz




Delphi-Quellcode:

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.


ich denke MulitFrameImage.Save( WideString(NewFilename), encoderClsid, nil ); ist falsch , aber mit
der Version MulitFrameImage.Save( WideString(NewFilename), encoderClsid, @encoderParameters ); bekomme ich eine AV
  Mit Zitat antworten Zitat