Board index » delphi » Storing Jpeg's in a blob field

Storing Jpeg's in a blob field

Whats the best way to do this? Personnaly i dont like TDBImage for several
reasons, you can only open a couple file formates, and you can only paste
from the clipboard in a couple file formats.  I do like using the standard
TImage for cut and pasting and file functions.  What Im interested in doing
is saving the picture in a jpeg format instead of bmp, this will save on
compression time when looking at them through a web interface.  Does anyone
know of a TJpegDBImage component? I cant seem to find one so I tried using
loadfromstream and savetostream using a TJpegImage in the hopes of allowing
any file format that TImage takes but always storing it as a jpeg in the
database.  Well I cant seem blob streaming working right.  Has anyone else
tried this before?

Blaine Whittle

 

Re:Storing Jpeg's in a blob field


1) store JPeg image in a TBlobField then use TImage to display it

Procedure Tform1.ShowImage;
var
   ms : TMemoryStream ;
   Jpeg: TJpegImage ;
begin
    Jpeg := TJpegImage.Create ;
    ms : TMemoryStream.Create ;
    try
        Tblobfield(Table1.Fieldbyname('StoredJpegImage')).SaveToStream(ms);
         ms.position := 0 ;
         Jpeg.LoadFromStream(ms);
         Image1.Picture.Graphic := Jpeg ;  // assuming you have Image1 on
your form
    finally
         jpeg.free ;
         ms.free ;
    end;
end;

Quote
R. Blaine Whittle wrote in message <7m3f0c$i9...@forums.borland.com>...
>Whats the best way to do this? Personnaly i dont like TDBImage for several
>reasons, you can only open a couple file formates, and you can only paste
>from the clipboard in a couple file formats.  I do like using the standard
>TImage for cut and pasting and file functions.  What Im interested in doing
>is saving the picture in a jpeg format instead of bmp, this will save on
>compression time when looking at them through a web interface.  Does anyone
>know of a TJpegDBImage component? I cant seem to find one so I tried using
>loadfromstream and savetostream using a TJpegImage in the hopes of allowing
>any file format that TImage takes but always storing it as a jpeg in the
>database.  Well I cant seem blob streaming working right.  Has anyone else
>tried this before?

>Blaine Whittle

Other Threads