Solved

displaying graphic from blob field

Posted on 2004-08-23
2
357 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 100 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now