Solved

displaying graphic from blob field

Posted on 2004-08-23
2
363 Views
Last Modified: 2010-04-05
In d3 I had a form with a dbimage control connected to a blob/memo field in an apollo Taptable

ie dbimage is a tdbimage
    datasource is the datasource connected to the database containing the bitmaps in its memofield  - "image"
   

i rerieve the size of the image using

   ih:=dbimage1.picture.Graphic.height;
   iw:=dbimage1.picture.Graphic.width;

then display this in a tpaintbox using (via a few subroutines)

   paintbox1.canvas.stretchdraw(rect(i,j,i+ih,j+iw),dbimage1.picture.graphic);

the form was converted to D7 with the aptable replaced by a Tapollotable but otherwise essentially the same.

using the same database for the two programs i find that the values of ih and iw are 0 in the D7 case and no image is displayed.

even manually overriding the size variables just displays an empty rectangle.

I tried to change the D7 version to us a timage rather than a tdbimage but can't work out have to assign the image in the blob field to the image control.

Any ideas why the d3 code  doesn't wrk in D7 or how to work around it?

Thanks

Kymberley

   

0
Comment
Question by:Kymberley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 11878224
well, cannot reproduce,

but you could try this way

var
  b : TBitmap;
  m : TmemoryStream;
begin
  b := TBitmap.Create;
  m := TmemoryStream.Create;
  try
    TBlobField(Dataset.FieldByName('Image')).SaveToStream(m);
    m.position := 0;
    b.LoadFromStream(m);
    //do your painting now
  finally
    b.free;
    m.free;
  end;
end;

just from head

meikl ;-)
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11883760
Do as meikl just told you. I do wonder though if the D7 version of Apollo is really backwards compatible with the D3 version of Apollo, especially since the classnames have changed. You might even want to save the blob field to a file and check the contents, just to see if it contains the correct data. Like:
  TBlobField(Dataset.FieldByName('Image')).SaveToFile('C:\Image.bmp');
Then see if it generates a file of more than 0 bytes and if the image is really a valid image.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question