Mirror

How to copy a *.bmp file from a floppy disc to a blob field (Views: 100)


Problem/Question/Abstract:

How to copy a *.bmp file from a floppy disc to a blob field

Answer:

procedure TForm1.Button1Click(Sender: TObject);
var
  tb: TBlobstream;
  tf: TFileStream;
begin
  table1.edit; {load from disk file and save in table}
  tf := TFileStream.create('splash.bmp', fmOpenRead);
  tb := TBlobstream.create(Table1PictureData, bmReadWrite);
  tb.CopyFrom(tf, 0);
  tf.free;
  tb.free;
  table1.post;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  tb: TBlobstream;
begin
  table1.active := true;
  if not (Table1.EOF) then
  begin
    Table1.first; {load from table and display}
    tb := TBlobstream.create(Table1PictureData, bmRead);
    Image1.Picture.Bitmap.LoadFromStream(tb);
    tb.free;
  end;
end;

<< Back to main page