2010. november 13., szombat
How to retrieve and display a TJPEGImage from a Paradox blob field
Problem/Question/Abstract:
How to retrieve and display a TJPEGImage from a Paradox blob field
Answer:
Solve 1:
Here's some code to fill a TImage on a form with a JPEGImage from a Paradox blob field:
var
Stream1: TBlobStream;
Photo: TJPEGImage;
begin
Stream1 := TBlobStream.Create(Table1.FieldByName('YourFieldName') as TBlobField, bmRead);
Photo := TJPEGImage.create;
try
Photo.LoadFromStream(Stream1);
Image1.Picture.Assign(Photo);
finally
Stream1.Free;
Photo.Free;
end;
end;
Solve 2:
Here is an example showing use of the TJPEGImage to display JPEG images in a TImage component. The JPEG data is stored in a Paradox BLOB field, and this routine is executed when the record pointer is moved in the table in order to display each new record's BLOB field contents.
procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
var
MS: TMemoryStream;
J1: TJPEGImage;
begin
J1 := TJPEGImage.Create;
MS := TMemoryStream.Create;
try
TBlobField(DataSet.Fields[1]).SaveToStream(MS);
MS.Seek(soFromBeginning, 0);
with J1 do
begin
PixelFormat := jf24Bit;
Scale := jsFullSize;
Grayscale := False;
Performance := jpBestQuality;
ProgressiveDisplay := True;
ProgressiveEncoding := True;
LoadFromStream(MS);
end;
Image1.Picture.Graphic.Assign(J1);
finally
J1.Free;
MS.Free;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése