Using PrintPreview component

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

Using PrintPreview component

Postby zvaranka » May 29th, 2003, 1:48 pm

Hi from Hungary...

My Name is Zoltán Varanka, I am working on a special map application
and I use the PrintPreview component developed by you. I have a big
problem. I have a topographic map loaded in an image on a form and
I'd like to print a part of this map, placing this part on the canvas of the
printpreview. How can I do it? I tried to use CopyRect function but it my
map is in JPEG format. On the preview from I made an Image that must
contain the part of the map but I don't know how fill this image
component with th part of the map. Can you help me?

Thank you!

Zoltán
:shock:
zvaranka
Member
Member
 
Posts: 2
Joined: May 29th, 2003, 1:45 pm

Postby Kambiz » May 29th, 2003, 3:17 pm

Hi Zoltán,

The image resolution differs from the print resolution, so you cannot copy an image with the same dimensions on the printer's canvas.

To have the right result on all kind of printers, you have scale the image to the printer resolution, and then the DIB Bitmap (Device Independent Bitmap) version of the image on the printer.

In the PrintPreview component, the PaintGraphic and PaintGraphicEx methods internally scale the image and convert it to DIB Bitmap. You can also avoid converting the image to DIB Bitmap by yourself, by setting the FastPrint property to False.

In your case, the easiest solution is to use an intermediate bitmap to copy the part of the image that you want to print, and then to call either PaintGraphic or PaintGraphicEx method for rendering it on the printer.

By the way, I moved your post to this forum, which is more related to your question.

Cheers,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby zvaranka » May 30th, 2003, 3:10 pm

Hi Kambiz!

Thank you very much for your advices, I could make the copy of the part of the map. I also have another question. Can the PrintPreview render transparent bitmaps? I have to place some triangles on the maps but it is necessary the triangles to be transparent. I made a bitmap un a bmp file with red triangle on white background but the white backgroun is rendered on the canvas of the preview and I want only the trianle be seen on the printing without white background.

Thank you.

Zoli
zvaranka
Member
Member
 
Posts: 2
Joined: May 29th, 2003, 1:45 pm

Postby Kambiz » May 31st, 2003, 12:45 am

The PaintGraphicEx method does not support transparency and you have to draw your bitmap directly using canvas. In this case, if your bitmap is not DIB you may need to set FastPrint property to False.

By the way, are you going to darw the triangles on your map? If yes, it's more effecient to draw the triangles on the intermediate bitmap, which you made it for copying part of the map.

Cheers,
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 27 guests

cron