D12 and (Font) Scaling and Printing

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Ed Dressel
Newbie
Newbie
Posts: 12
Joined: Wed Aug 16, 2023 12:00 am

D12 and (Font) Scaling and Printing

Post by Ed Dressel » Tue Mar 26, 2024 5:51 pm

D12, Windows 11

D12 does a lot to improve the Scaling issues, and for the GUI, it looks good. But when I go to print, I want to turn off the scaling for TCharts so that the reports have the correct font size (rather than scaled-up font size).

This is the chart image I see when the display is scaled to 100% (which is what I want to see--images don't seem to be working, so I will just provide the links):

Image

But when the display is scaled, I see this:

Image

If the display is scaled, how do I create an image from a TChart for reports so the font is not scaled? Here is the procedure I currently use:

Code: Select all

procedure AssignChartToGraphic(aChart: TChart; const aRect: TRect; aGraphic: TGraphic; aTransparent: boolean = false);
var
  lHoldShadow: boolean;
  I: Integer;
  lBoolArray: array of boolean;
  lHoldBevel: TBevelCut;
  lHoldColor: TColor;
  lHoldGradientVisible: boolean;
  lMetafile: TMetafile;
  lBmp: TBitmap;
  lCanvasClass: TCanvas3DClass;
  lHoldHover: Boolean;
begin
  lCanvasClass := TCanvas3DClass(aChart.Canvas.ClassType);
  if lCanvasClass <> TTeeCanvas3D then
    aChart.Canvas := TTeeCanvas3D.Create;

  lHoldGradientVisible := aChart.Gradient.Visible;
  lHoldColor := aChart.Color;
  lHoldBevel := aChart.BevelOuter;
  lHoldShadow := aChart.Shadow.Visible;
  lHoldHover := aChart.Hover.Visible;

  try
    SetLength(lBoolArray, aChart.SeriesCount);
    for I := 0 to aChart.SeriesCount - 1 do    // Iterate
      if aChart.Series[I] is TPieSeries then begin
        lBoolArray[I] := TPieSeries(aChart.Series[I]).Circled;
        TPieSeries(aChart.Series[I]).Circled := True;
      end else
        lBoolArray[I] := True;


    aChart.Gradient.Visible  := false;
    if not aTransparent then
      aChart.Color := clWhite
    else
      aChart.Color := Graphics.clNone; //clWhite;
    aChart.BevelOuter := bvNone;
    aChart.BevelInner := bvNone;
    aChart.Shadow.Visible := False;
    aChart.Hover.Visible := false;

    if aGraphic is TMetafile then begin
      lMetafile := aChart.TeeCreateMetafile(false, aRect);
      try
        aGraphic.Assign(lMetafile);
      finally
        lMetafile.Free;
      end;
    end else begin
      lBmp := aChart.TeeCreateBitmap(clWhite, aRect);
      try
        aGraphic.Assign(lBmp);
      finally
        lBmp.Free;
      end;
    end;
  finally
    aChart.Hover.Visible := lHoldHover;
    aChart.Shadow.Visible := lHoldShadow;
    aChart.Gradient.Visible := lHoldGradientVisible;
    aChart.Color := lHoldColor;
    aChart.BevelOuter := lHoldBevel;
    for I := 0 to aChart.SeriesCount - 1 do    // Iterate
      if aChart.Series[I] is TPieSeries then
        TPieSeries(aChart.Series[I]).Circled := lBoolArray[I];
    if (lCanvasClass <> aChart.Canvas.ClassType) then
      aChart.Canvas := lCanvasClass.Create;
    if assigned(aChart.OnResize) then
      WrapLeftAxisTitle(aChart, aChart.Height);
  end;
end;
Much appreciated,

Ed Dressel

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: D12 and (Font) Scaling and Printing

Post by Yeray » Wed Mar 27, 2024 11:45 am

Hello,

I've copied your code to a simple example with just a THorizBarSeries, and this is how it looks for me:
ScalingGraphic.zip
(2.29 KiB) Downloaded 3655 times
At 100%:
scalingGraphic.png
scalingGraphic.png (18.55 KiB) Viewed 27441 times
At 175%, the forums seem to rescale the image - open it in a new tab to see the real size:
scalingGraphic_175.png
scalingGraphic_175.png (41.03 KiB) Viewed 27441 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Ed Dressel
Newbie
Newbie
Posts: 12
Joined: Wed Aug 16, 2023 12:00 am

Re: D12 and (Font) Scaling and Printing

Post by Ed Dressel » Wed Mar 27, 2024 3:10 pm

Delphi 12,
TeeChart 2023.39.231109 32-bit

Thank you for the quick response. Here is what I get with your demo:

Chart with 100% scaling.

Image

URL: http://www.tbinc.com/misc/ChartScale100.jpg

And at 200%:

Image

URL: http://www.tbinc.com/misc/ChartScale200.jpg

(Any idea why my image tags do not work?)

How do I prevent scaling the created image? It ends up looking bad in the printed report.

Ed Dressel
Newbie
Newbie
Posts: 12
Joined: Wed Aug 16, 2023 12:00 am

Re: D12 and (Font) Scaling and Printing

Post by Ed Dressel » Mon Apr 01, 2024 2:36 pm

This issue is keeping me from posting an update on my application. Any ideas on how to solve it?

Ed Dressel
Newbie
Newbie
Posts: 12
Joined: Wed Aug 16, 2023 12:00 am

Re: D12 and (Font) Scaling and Printing

Post by Ed Dressel » Tue Apr 02, 2024 2:32 pm

I found a solution. Calling:

Code: Select all

aChart.ScaleForPPI(100);
before generating the graphic fixes this, and then

Code: Select all

aChart.ScaleForPPI(0);
resets the chart.

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: D12 and (Font) Scaling and Printing

Post by Yeray » Wed Apr 03, 2024 5:55 am

Hello,

I'm sorry for the delay replying here.
But I'm glad to hear you found the solution yourself. And thanks for sharing it!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply