Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

displaying graphic from blob field

Posted on 2004-08-23
2
Medium Priority
?
370 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
2 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

885 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