Hi everyone, again, just to report this (I believe important reach): My application now DOES handle either JPEG or BitMap images in the same column, Blob-Type, without having to regard imagefile extension, nor having to decipher Blob-headers.
In my application, the instructions will be to use only .bmp or JPEG files, which are loaded into the database by means of the loadpicture dialog. The loading of the image file it is known, does not discriminate: can load JPEG or .bmp by same code. These two image types, for me, are the most popular here. But the idea can possibly be extended to a few other types if needed, I believe.
The usual problem has been, not the loading, but the SHOWING the Blob image when the Blob column can store Blobs of JPEG or .bmp files. Of course, the idea can be extended to include other image formats.
The solution achieved is using Exception coding as follows:
// var
// BlobField: TField;
// BS: TStream;
with SQLQuery1 do
begin
BlobField := FieldByName('Pic'); {'Pic' is name of column with photo}
BS := CreateBlobStream(BlobField,bmRead);
Image1.Picture.Graphic:= TJpegImage.Create; {assume is Jpeg}
Try
Image1.Picture.Graphic.LoadFromStream(BS); {error if not Jpeg}
Except {repeat steps for BitMap}
BS.Free;
Image1.Picture.Graphic:= nil; {empty}
BlobField := FieldByName('Pic'); {'Pic' is name of column with photo}
BS := CreateBlobStream(BlobField,bmRead);
Image1.Picture.Graphic:= TBitMap.Create; {bitmap}
Image1.Picture.Graphic.LoadFromStream(BS);
end; {Try}
BS.Free;
end; {with SQLQuery}
Thanks to taazz for the very good observation on WHERE to do the exception, and to all others as well.