Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying an image from a Database to a Image

Status
Not open for further replies.

Ginka

Programmer
Mar 18, 2005
54
MX
How can I extract the value of a BLOB type to an Image component without using a DBImage?

Like this:
Image.Picture.Bitmap = ImageField.Value;


I tried using this:

Image.Picture.Bitmap = ImageField.AsBCD;

I guess I need to cast but how?
 
You can use a component that accepts LoadFromStream.

In Jedi 3.0, palette JVCLGlobus1, there is JvgBitmapImage component.

(or you can download Globus Components from here:

or you can search on torry's ....

Use it so:

Code:
procedure TForm1.Button1Click(Sender: TObject);
var b : TBlobStream;
    m : TMemorystream;
begin
  query.Open;
    b := TBlobStream.Create(queryimagefield, bmRead);
    try
      m := TMemoryStream.create;
        try
          m.CopyFrom(b,b.Size);
          JvgBitmapImage1.Bitmap.LoadFromStream(m);
        finally
          m.Free;
        end;
      finally
        b.free;
        mq.Close;
    end;
end;
[code]

Hope this can help you
Giovanni Caramia
 
You can also use standard Image component in Delphi:
Image1.Picture.Bitmap.LoadFromStream(m)

Giovanni Caramia

 
Hi.

This works as long as the bitmap is smaller than 65 kBytes or the use of dbExpress.
If the bitmap is larger and you are using BDE, you get a Blob length error.

If you want to download files larger than 65 KBytes, you have to use Live tables, and add unique index on the table.





KungTure-RX.jpg

//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top