Board index » delphi » Display Gif or Jpeg Images on dbImage

Display Gif or Jpeg Images on dbImage

Ive been using a paradox database with a graphic field to store images.

If I use bmp files, I can display them on a dbImage, but if I use gif or
jpeg, I get only blank screens.
I can display them on a Iame, but not on a dbImage.

Any ideas on how to solve that?

Thanks in advance
David Gurevitz
g...@centroin.com.br

 

Re:Display Gif or Jpeg Images on dbImage


Quote
>Ive been using a paradox database with a graphic field to store images.

>If I use bmp files, I can display them on a dbImage, but if I use gif or
>jpeg, I get only blank screens.
>I can display them on a Iame, but not on a dbImage.

You will not be able to display Jpegs in a tdbimage.  You can write code to read
a jpeg from a blob field and display it in a timage.

here is some code to help you get started
procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
var
  MS: TMemoryStream;
  J1: TJPEGImage;
begin
  J1 := TJPEGImage.Create;
  MS := TMemoryStream.Create;
  try
    TBlobField(DataSet.fieldbyName('yourJpeg')).SaveToStream(MS);
    MS.Seek(soFromBeginning, 0);
    with J1 do begin
      PixelFormat := jf24Bit;
      Scale := jsFullSize;
      Grayscale := False;
      Performance := jpBestQuality;
      ProgressiveDisplay := True;
      ProgressiveEncoding := True;
      LoadFromStream(MS);
    end;
    Image1.Picture.Graphic.Assign(J1);
  finally
    J1.Free;
    MS.Free;
  end;
end;

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Display Gif or Jpeg Images on dbImage


Thanks fro your answeer Brian.

But in that case, is it a good idea to save the graphic in a Blob field, or it will
be better to save only the full path/name of the jpeg file and open it on a TImage?

What will be the best/quicker way?

Thanks
David

Quote
Brian Bushay TeamB wrote:
> >Ive been using a paradox database with a graphic field to store images.

> >If I use bmp files, I can display them on a dbImage, but if I use gif or
> >jpeg, I get only blank screens.
> >I can display them on a Iame, but not on a dbImage.

> You will not be able to display Jpegs in a tdbimage.  You can write code to read
> a jpeg from a blob field and display it in a timage.

> here is some code to help you get started
> procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
> var
>   MS: TMemoryStream;
>   J1: TJPEGImage;
> begin
>   J1 := TJPEGImage.Create;
>   MS := TMemoryStream.Create;
>   try
>     TBlobField(DataSet.fieldbyName('yourJpeg')).SaveToStream(MS);
>     MS.Seek(soFromBeginning, 0);
>     with J1 do begin
>       PixelFormat := jf24Bit;
>       Scale := jsFullSize;
>       Grayscale := False;
>       Performance := jpBestQuality;
>       ProgressiveDisplay := True;
>       ProgressiveEncoding := True;
>       LoadFromStream(MS);
>     end;
>     Image1.Picture.Graphic.Assign(J1);
>   finally
>     J1.Free;
>     MS.Free;
>   end;
> end;

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Display Gif or Jpeg Images on dbImage


Quote
>But in that case, is it a good idea to save the graphic in a Blob field, or it will
>be better to save only the full path/name of the jpeg file and open it on a TImage?

>What will be the best/quicker way?

With a database of any size you will end up with a lot of files.   I believe
storing them in a blob field is the easier option from a maintenance stand
point.  

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Display Gif or Jpeg Images on dbImage


Thanks, Brian.

Other question:
I was using a dbImage to assign a bmp value to a Blob field. This doesn't function to
Jpeg files.
How do I assign a Jpeg value to a Blob field directly?

Regards
David

Quote
Brian Bushay TeamB wrote:
> >But in that case, is it a good idea to save the graphic in a Blob field, or it will
> >be better to save only the full path/name of the jpeg file and open it on a TImage?

> >What will be the best/quicker way?

> With a database of any size you will end up with a lot of files.   I believe
> storing them in a blob field is the easier option from a maintenance stand
> point.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Display Gif or Jpeg Images on dbImage


Quote
>How do I assign a Jpeg value to a Blob field directly?

You can use the Tblobfield loadfromFile and LoadFromStream methods to store a
jpeg.  The Tjpegimage has a SaveToStream

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads