Print in Grayscale

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Print in Grayscale

Post by bertrod » Wed Oct 31, 2007 12:18 pm

Hello,

I'm using the feature TeeGrayScale() in the afterDraw method, but I can't use it also to pring the chart in grayscale. Is it possible ? Thanks

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 Oct 31, 2007 12:44 pm

Hi bertrod,

You can try something like what Marjan suggested here and adding this line:

Code: Select all

      pDMode^.dmColor:=DMCOLOR_MONOCHROME;
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

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Wed Oct 31, 2007 1:02 pm

Hi Narcis,

Ok but my problem is that Monochrome is different than Grayscale :

chart.monochrome looks different than teeGrayscale(), and moreover i'm also using the reverted grayscale (white becomes black, etc.).

Seeing your answer, I should understand that you did not yet implement the printing in the "real" grayscale ?

If not, then i will use your proposition for now, and I hope printing in grayscale will be implemented in the next releases.

Regards

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Nov 07, 2007 12:01 pm

Hi bertrod,

to create a grayscale Chart you must use (as you said) the TeeGrayScale, and to be able to print it in grayscale you will have to use a Metafile and StretchDraw method to print it directly.

Code: Select all


procedure TForm1.BitBtn2Click(Sender: TObject);
var meta : TMetafile;
begin
   Chart1.BevelOuter := bvNone;
   Meta := Chart1.TeeCreateMetafile(True, Chart1.ClientRect);
   try
      Printer.Orientation := poPortrait;
      Printer.BeginDoc;
      try
         Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1,
         Printer.PageHeight - 1),Meta);
      finally
         Printer.EndDoc;
      end;
   finally
      Meta.Free;
      Chart1.BevelOuter := bvRaised;
   end;
end;

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Thu Nov 08, 2007 1:18 pm

Hi Pep,

Thanks for the answer but your solution doesn't work. I'm using the filter right before creating the Metafile, and then I'm using it to print, but the chart is still not in grayscale.

Code: Select all

TeeGrayScale((Chart.Canvas as TTeeCanvas3D).Bitamp, true, 0) ;
MetaChart := Chart.TeeCreateMetaFile(True, Chart.ClientRect) ;
...
Do you have maybe another solution ?

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Sun Nov 11, 2007 11:47 am

Hello,

Try this:

var bit: TBitmap;
begin
bit := Chart.TeeCreateBitmap(clwhite, Chart.ClientRect);
TeeGrayScale(bit, false, 0) ;
MetaChart := Chart.TeeCreateMetaFile(True, Chart.ClientRect) ;
bit.free;
..............
end;

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Mon Nov 12, 2007 7:51 am

Hi johnnix,

I don't see the point in your solution. The Metachart is still in color and bit is never used :?:

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Mon Nov 12, 2007 7:55 am

Hello,

Use the bitmap for printing and not the metafile.

Regards

bertrod
Advanced
Posts: 151
Joined: Wed Sep 07, 2005 4:00 am

Post by bertrod » Mon Nov 12, 2007 8:04 am

Ok, well yes it does work, but the quality of the bitmap is far not as good as the MetaFile when stretched, zoomed, etc. I'll try to see if I can improve it.

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Post by johnnix » Mon Nov 12, 2007 8:11 am

Hello,

I use that portion of code to place my plots inside FastReports and works pretty nice. You may try to double the size of the bitmap in order to get more details...

Regards

Post Reply