Custom drawn bitmap does not print

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
spt
Newbie
Newbie
Posts: 8
Joined: Mon Feb 20, 2006 12:00 am

Custom drawn bitmap does not print

Post by spt » Wed May 03, 2006 2:18 pm

My problem: Custom bitmap drawn on the teechart canvas from the AfterDraw event does not print.

I have seen several other reporting a similar problem on this forum , but I haven't seen any solution to it (other that "it should work"). I therefore hope there is a possibility for a resolution now.

Here is the situation: Using BCB 6 and TeeChart v7.06 with the following code

Code: Select all

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    Series1->FillSampleValues(50);
    bitmap_ = new Graphics::TBitmap;
    bitmap_->LoadFromFile("C:\\tmp\\logo60.bmp");
}

void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
    Chart1->Canvas->Draw(5,5,bitmap_);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    ChartPreviewer1->Execute();
}
I am using the ChartPreviewr to show and print the chart. My bitmap shows fine on the chart and also in the print preview window, but not on paper. There is only the standard chart.

Any ideas?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed May 03, 2006 2:42 pm

Hi spt,

It works fine for me here using BCB 6 and TeeChart Pro v7.07. I've created an example which I'm going to send to your forums contact e-mail address. Can you please test if the already built .exe works at your end?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

spt
Newbie
Newbie
Posts: 8
Joined: Mon Feb 20, 2006 12:00 am

Post by spt » Wed May 03, 2006 7:06 pm

The example you sent indicates what the problem is. Since you where using a much bigger bitmap than me, I was able to get something on paper, but not the whole bitmap. Only the bottom right quarter of the bitmap is printed. The rest of the image is pushed outside the printable area. Note: this is using default print options which is Landscape mode and print margins L: 15, T: 23, R: 15, B: 23; Proportional on and Smooth off.

Experimenting some more with my own example I was able to get the bitmap printed in the right position if I either print as bitmap (Smooth on in Print preview) or if I set all the print margins to 0%.

It seems that when using absolute positioning of the bitmap it shows in the right position on screen (including in the print previewer), but when printed the position is related to the actual paper size and not the box defined by the print margins. Is there any way that I can position the bitmap relative to the print margins or do you recommend to always print as bitmap? I see when I print as bitmap, dashed lines is actually printed as dashed lines which is quite useful. :D

Lars

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 04, 2006 8:09 am

Hi Lars,

Ok, to have the chart properly positioned you should use a position relative to the chart. i.e.: axes position, ChartRect position, etc. So you can use something like this:

Code: Select all

void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
    Chart1->Canvas->Draw(Chart1->Axes->Left->PosAxis,
                        Chart1->Axes->Bottom->PosAxis-bitmap_->Height,bitmap_);
}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

spt
Newbie
Newbie
Posts: 8
Joined: Mon Feb 20, 2006 12:00 am

Post by spt » Thu May 04, 2006 10:34 am

Thanks for the help. I ended up using ChartRect as I wanted to position the bitmap outside the plot area and not rely on axis that may or may not be active. I noticed that axes that are not connected to a series return a PosAxis of 0.

So the conclusion on this is to always draw using position relative to ChartRect or PosAxis to get the custom drawing in the right position both on screen and on print. This should be a FAQ. :wink:

Thanks
Lars

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu May 04, 2006 10:38 am

Hi Lars,

I'm glad to hear you could make this work. I've written down your FAQ's suggestion and we will consider it when reviewing the FAQ section.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply