Recent

Author Topic: Trying to show Bitmap photo, get error Bitmap with unknown compression.  (Read 4846 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Windows-7, Lazarus 32 bit
SQLite3 database.

Hi everyone,

Still trying to show photo from Grid.

The app is OK so far, except when current grid field is at column named 'Pic' (which holds the photo) that is to show in Image1 box (TImage), I get the error :

DEBUGGER EXCEPTION NOTIFICATION:
class FPIMageException with message: Bitmap with unknown compression(8077443525)
   

and I have not been able to find out the problem.

The procedure runs when the cursor enters a grid field, and if the field datatype is Blob, then the field's image is to be shown in box Image1.

Could it be my code?  Is there perhaps a known problem that I need to know about concerning the showing of images, that I am not properly addressing?

Would appreciate help.

Thanks.

Code: [Select]
//Am getting: DEBUGGER EXCEPTION NOTIFICATION:
//class FPIMageException with message: Bitmap with unknown compression(8077443525)
procedure TForm1.DBGrid1ColEnter(Sender: TObject);
  var
  BlobField: TField;
  BS: TStream;
  {L_FieldDataType is a TLabel;}
  {'Pic' is the SQLITE3 column name with photograph with format .bmp}
  {Image1 is component on Form1 type TImage}
BEGIN
  L_FieldDataType.Caption:=Fieldtypenames[dbgrid1.SelectedField.DataType];
  if L_FieldDataType.Caption = 'Blob' then
  Begin
  with SQLQuery1 do
    begin
    BlobField := FieldByName('Pic'); {'Pic' is name of column with photo}
    BS := CreateBlobStream(BlobField,bmRead);
    Image1.Picture.Graphic:= TBitmap.Create;
    Image1.Picture.Graphic.LoadFromStream(BS);
    BS.Free;
    end;
  END;
END;   
« Last Edit: July 18, 2012, 05:51:23 am by Elmug »

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
What happens if you load like this:

Code: Pascal  [Select][+][-]
  1. Image1.Picture.LoadFromStream(BS);

instead of

Code: Pascal  [Select][+][-]
  1. Image1.Picture.Graphic:= TBitmap.Create;
  2. Image1.Picture.Graphic.LoadFromStream(BS);

 

TinyPortal © 2005-2018