Re: Saving Image/Picture to Database using ADO




I tried both of theses options and still get the same 'Bitmap Image is
Invalid' Error message.

qryCompanyLOGO.LoadFromFile(SPicFileName);
(qryCompany.fieldbyName('LOGO') as TblobField).loadFromfile(SPicFileName);

The jpeg is valid because it will load into my DBImage with the following
code:
A dbImage will only display bitmap graphics
If you are trying to use a dbImage to directly display a jpeg that is your
problem.
You need to use a Timage to display a jpeg
here is some code you can use to load a jpeg to a timage

procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
var
MS: TMemoryStream;
J1: TJPEGImage;
begin
J1 := TJPEGImage.Create;
MS := TMemoryStream.Create;
try
TBlobField(DataSet.Fieldbyname('myBlob')).SaveToStream(MS);
MS.Seek(0,soFromBeginning);
with J1 do begin
PixelFormat := jf24Bit;
Scale := jsFullSize;
Grayscale := False;
Performance := jpBestQuality;
ProgressiveDisplay := True;
ProgressiveEncoding := True;
LoadFromStream(MS);
end;
if MS.Size >0 then
Image1.Picture.Assign(J1)
else
Image1.Picture.Assign(nil);

finally
J1.Free;
MS.Free;
end;
end;

--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.


Quantcast