Recent

Author Topic: TDBImage doesn't show BLOB image from MySQL via Zeos Win/Lin  (Read 13016 times)

paragente

  • Newbie
  • Posts: 1
TDBImage doesn't show BLOB image from MySQL via Zeos Win/Lin
« on: April 05, 2006, 10:02:02 pm »
I've tried to display a BLOB image from a working environment using Zeoslib, MySQL 5 (win and lin) compiled with Zeoslib_rework in also both environments, no results.

Tried to assign the query results manually but it seems that the TZquery is not returning anything.

I'm still searching any previous posts and figuring out the solution.

Any help will be appreciated.


Mike

cohako

  • Newbie
  • Posts: 1
RE: TDBImage doesn
« Reply #1 on: May 02, 2006, 04:06:22 am »
I obtained success making "a bridge", using TStream. See you the way that I made:

TO SHOW:
//procedure to show date
:
:
var
  Stream: TStream;
begin
  :
  :
  ZQuery1.open;
  Stream:= TMemoryStream.Create;  
  Stream := ZQuery1.CreateBlobStream(ZQuery1.FieldByName('image'), bmRead); //Transferring the field image to the Stream
  Stream.Position:=0;
  DBImage1.Picture.Bitmap.LoadFromStream(Stream);   //Loading the stream image to the DBImage
  Stream.Free;                                     //I think that is better to use TImage, not TDBImage
  :
  :
end;  

TO SAVE:
//procedure to save date
:
:
var
  Stream: TStream;
begin
   :
   :
   Stream:= TMemoryStream.Create;
   DBImage_logotipo.Picture.Bitmap.SaveToStream(Stream); //Transferring the field image to the Stream
                                                         //I think that is better to use TImage, not TDBImage
   with ZUpdateSQL1 do
   begin
     ModifySQL.Text := 'update table_image ' +
                       ' set image_id = :image_id, ' +
                       '     image  = :param_iamge';  
     Params.ParamByName('param_image').DataType := ftBlob;
     Params.ParamByName('param_image').ParamType := ptInput;
     Params.ParamByName('param_image').LoadfromStream(Stream,ftBlob); //Loading the stream image to the parameter
   end;
   ZQuery1.Post;
   :
   :
end;

However this code worket with PostgreSQL.

Joe

  • New Member
  • *
  • Posts: 24
Re: TDBImage doesn't show BLOB image from MySQL via Zeos Win/Lin
« Reply #2 on: June 05, 2013, 12:36:38 am »
The problem could be, that the TBDImage implementation puts / expects "Picture.Graphic.GetFileExtensions" into/from the stream and for that reason the saved data becomes incompatible to other tools (like pgAdmin or LibreOffice Base et cetera).
I'd made my own Load/Save methods without that FileExtensions (saving the raw filedata of the imagefiles into the blob stream) and it works.
See also http://bugs.freepascal.org/view.php?id=24539.
See also http://wiki.lazarus.freepascal.org/Lazarus_1.2.0_release_notes#TDBImage

 

TinyPortal © 2005-2018