Einzelnen Beitrag anzeigen

calikey

Registriert seit: 19. Mär 2015
29 Beiträge
 
Delphi XE7 Architect
 
#47

AW: JPG im Blob Feld wird extrem groß

  Alt 18. Apr 2015, 16:16
So quellcode
bei BlobStream.Free; meldet er denn hinweis
Delphi-Quellcode:
type
  TForm2 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    odBlob: TOpenDialog;
    sdBlob: TSaveDialog;
    Button3: TButton;
    frxReport1: TfrxReport;
    Photo: TImage;
    
    procedure btnLoadClick(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure tPhotoAlbumAfterScroll(ClientDataSet1: TClientDataSet);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;


implementation

{$R *.dfm}

uses Unit1, ABOUT;



procedure TForm2.btnLoadClick(Sender: TObject);
var
  FileStream: TFileStream;
  BlobStream: TStream;
begin
  if sdBlob.Execute then
  BlobStream := nil;
  FileStream := TFileStream.Create(sdBlob.FileName,fmCreate);
  begin
    Form1.clientdataset1.Edit;
    try
      BlobStream := Form1.clientdataset1.CreateBlobStream(Form1.clientdataset1.FieldByName('Arbeitsvertragimg')AS TBlobField, bmWrite );
      FileStream.CopyFrom(BlobStream,BlobStream.Size-BlobStream.Position);
      Form1.clientdataset1.Post;
    finally
      BlobStream.Free; // hier ist der hinweis
      FileStream.Free;
      Form1.clientdataset1.Post;
      tPhotoAlbumAfterScroll (Form1.clientdataset1)

    end;
  end;
end;

procedure TForm2.Button12Click(Sender: TObject);
begin
frxreport1.showreport;
end;

procedure TForm2.Button13Click(Sender: TObject);
var
  FileStream: TFileStream;
  BlobStream: TStream;
begin
  if (sdBlob.Execute) then
    begin
      FileStream := TFileStream.Create(sdBlob.FileName,fmCreate);
      BlobStream := Form1.clientdataset1.CreateBlobStream(Form1.clientdataset1.FieldByName('Arbeitsvertragimg'),bmRead);
      FileStream.CopyFrom(BlobStream,BlobStream.Size-BlobStream.Position);
      BlobStream.Free;
      FileStream.Free;
    end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.clientdataset1.Open;
end;

procedure TForm2.tPhotoAlbumAfterScroll(ClientDataSet1: TClientDataSet);
var
  JpegImage: TJPEGImage;
  BlobStream: TStream;
begin
  if (not Form1.clientdataset1.FieldByName('Arbeitsvertragimg').IsNull) then
    begin
      BlobStream := Form1.clientdataset1.CreateBlobStream(Form1.clientdataset1.FieldByName('Arbeitsvertragimg'),bmRead);
      JpegImage := TJPEGImage.Create;
      try
        JpegImage.LoadFromStream(BlobStream);
        Photo.Picture.Assign(JpegImage);
        Photo.Visible := True;
      finally
        JpegImage.Free;
        BlobStream.Free;
      end;
    end
  else
    Photo.Visible := False;
end;


END.
  Mit Zitat antworten Zitat