Page 1 of 1

Print in Grayscale

Posted: Wed Oct 31, 2007 12:18 pm
by 9343260
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

Posted: Wed Oct 31, 2007 12:44 pm
by narcis
Hi bertrod,

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

Code: Select all

      pDMode^.dmColor:=DMCOLOR_MONOCHROME;

Posted: Wed Oct 31, 2007 1:02 pm
by 9343260
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

Posted: Wed Nov 07, 2007 12:01 pm
by Pep
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;

Posted: Thu Nov 08, 2007 1:18 pm
by 9343260
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 ?

Posted: Sun Nov 11, 2007 11:47 am
by 10046032
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;

Posted: Mon Nov 12, 2007 7:51 am
by 9343260
Hi johnnix,

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

Posted: Mon Nov 12, 2007 7:55 am
by 10046032
Hello,

Use the bitmap for printing and not the metafile.

Regards

Posted: Mon Nov 12, 2007 8:04 am
by 9343260
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.

Posted: Mon Nov 12, 2007 8:11 am
by 10046032
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