Recent

Author Topic: [SOLVED] Read Picture from Postgresql Database Unknown Picture Format [blob]  (Read 1572 times)

heejit

  • Full Member
  • ***
  • Posts: 245
Code: Pascal  [Select][+][-]
  1.  
  2. Working :
  3.  astream : TStream
  4.  astream := m_qry.CreateBlobStream(m_qry.FieldByName('file_data'), bmRead);
  5.  self.imgWidget.Picture.LoadFromStream(astream);
  6.  
  7. Not Working : Unknown Picture Format
  8.   astream : TMemoryStream
  9.  TBlobField(self.m_qry.FieldByName('file_data')).SaveToStream(astream);
  10.  self.imgWidget.Picture.LoadFromStream(astream);
  11.  

In documentation also it suggested to use TBlobField  :
https://www.freepascal.org/docs-html/fcl/db/tdataset.createblobstream.html

Then why there is format Error?

Development Env:
Lazarus   : 2.0
Feepascal : 3.0.4
SVN Rev   : 60350M
OS        : Linux 64bit Ubuntu 16.04
« Last Edit: March 31, 2019, 03:10:00 pm by jshah »

heejit

  • Full Member
  • ***
  • Posts: 245
Solved
We need to move the position of stream to beginning

astream.Position:=0;

 

TinyPortal © 2005-2018