TPrintPreview from a blob (bitmap) database field

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPrintPreview from a blob (bitmap) database field

Postby danzman » December 31st, 2005, 12:20 am

Is there a way I can directly assign the bitmap field into PrintPreview? Can you show me some code?
thanks
POGEE Systems & Technologies
Home of Affordable Solutions
danzman
Active Member
Active Member
 
Posts: 10
Joined: December 30th, 2005, 11:13 pm

Postby Johnny_Bit » December 31st, 2005, 9:09 am

Gosh... It's in the examples... You just draw bitmap on page and that's all.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby danzman » December 31st, 2005, 1:33 pm

What I am looking for is NOT dragging, it is something like this

TImage.picture.assign(DBImageField).

Can you tell me where in the samples is a statement similar to this?
Thanks
Gosh
POGEE Systems & Technologies
Home of Affordable Solutions
danzman
Active Member
Active Member
 
Posts: 10
Joined: December 30th, 2005, 11:13 pm

Postby Kambiz » December 31st, 2005, 1:59 pm

You have to provide the image before drawing it on the PrintPreview's canvas. As a simple solution, you can put an invisible DBImage on the form and use it for retrieving image from the database.

By the way, TPrintPreview is a low level printing tool, and you might not consider it as a report generator.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby danzman » December 31st, 2005, 3:00 pm

I managed to create the DBImage and it works fine. Now I need to transfer this image to PrintPreview so that I can zoom, rotate and print the image. How do I do it from here?
POGEE Systems & Technologies
Home of Affordable Solutions
danzman
Active Member
Active Member
 
Posts: 10
Joined: December 30th, 2005, 11:13 pm

Postby Kambiz » December 31st, 2005, 3:17 pm

Now, DBImage1.Picture.Graphic contains the image, and you can use this property and one of PaintGraphic, PaintGraphcEx, or PaintGraphicEx2 methods of PrintPreview to draw the image on the PrintPreview's canvas.

Note: if DBImage1 has no image, DBImage1.Picture.Graphic could be nil. Therefore, you should check this condition otherwise you'll get an AV.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby danzman » December 31st, 2005, 3:38 pm

I did something like this:

PrintPreview1.PaintGraphic(DbImage1.Width,DBImage1.Height,DBImage1.Picture.Graphic);

I got the runtime error: "Printer is not currently printing"

BTW, do I have the right X, Y values?
POGEE Systems & Technologies
Home of Affordable Solutions
danzman
Active Member
Active Member
 
Posts: 10
Joined: December 30th, 2005, 11:13 pm

Postby Johnny_Bit » December 31st, 2005, 9:03 pm

You must do everything like on a normal printer, so BeginDoc, EndDoc and so on.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » January 1st, 2006, 12:09 am

X and Y are the picture coordinates on the canvas.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby danzman » January 2nd, 2006, 3:10 pm

Hi Kambiz and Johnny - thanks for the help. I got it to work with your suggestions. For the benefit of others here is what I did -

(code snippet)

PrintPreview1.BeginDoc;
PrintPreview1.PaintGraphic(DbImage1.Picture.Width,DBImage1.Picture.Height,DBImage1.Picture.Graphic);
PrintPreview1.EndDoc;

Now All I need to do is to be able to zoom (resize), rotate and print the image. I know you will hear from me about this but let me do a little work and study your component a little more.

Thanks again
POGEE Systems & Technologies
Home of Affordable Solutions
danzman
Active Member
Active Member
 
Posts: 10
Joined: December 30th, 2005, 11:13 pm

Postby Kambiz » January 3rd, 2006, 11:43 am

DbImage1.Picture.Width and DBImage1.Picture.Height as X and Y parameters are wrong. PaintGraphic works like Draw method of a Canvas.

For resizing the image you can use PaintGraphicEx method instead of PaintGraphic. PaintGraphicEx works more or less like StretchDraw method of the canvas.

Please look at readme.htm for documentations.

TPrintPreview dosn't do anything with image rotation. You may use either TRotateImage Component or Image Work Package.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 3 guests

cron