Displaying bmp and jpg in a same TImage
Hello, I use following code to display a bitmap in a timage:
Bmp:=TBitmap.Create;
TBLOBField(dbMembres_Foto.FieldByName('FOTO')).SaveToStream(aStream);
aStream.Position:=0;
Bmp.LoadFromStream(aStream);
dbBitmap1.Picture.Graphic:=Bmp;
dbBitmap1.Visible:=True;
And I use similar code to do this with a jpeg:
Jpg:=TJpegImage.Create;
TBLOBField(dbMembres_Foto.FieldByName('FOTO')).SaveToStream(aStream);
aStream.Position:=0;
Jpg.LoadFromStream(aStream);
dbBitmap1.Picture.Graphic:=Jpg;
dbBitmap1.Visible:=True;
*** BUT: when I run the program, I get the error : "JPEG Error #052" when
I want to use a .bmp ???? Why is that?
Below you see the complete code-chunk for this, where it runs one of the
above depending on the BLOB-type....
I would appreciate it a lot if someone could give me an answer on this...
aStream:=TMemoryStream.Create;
aExtention:=FieldByNAme('Formaat').AsString;
if (aExtention='bmp') then
begin
Bmp:=TBitmap.Create;
TBLOBField(dbMembres_Foto.FieldByName('FOTO')).SaveToStream(aStream);
aStream.Position:=0;
Bmp.LoadFromStream(aStream);
dbBitmap1.Picture.Graphic:=Bmp;
dbBitmap1.Visible:=True;
end
else
begin
Jpg:=TJpegImage.Create;
TBLOBField(dbMembres_Foto.FieldByName('FOTO')).SaveToStream(aStream);
aStream.Position:=0;
Jpg.LoadFromStream(aStream);
dbBitmap1.Picture.Graphic:=Jpg;
dbBitmap1.Visible:=True;
end;
aStream.Free;