Charts, Images and Display Settings

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Ed Dressel
Newbie
Newbie
Posts: 28
Joined: Tue Dec 05, 2017 12:00 am

Charts, Images and Display Settings

Post by Ed Dressel » Wed May 09, 2018 7:34 pm

I create images from TCharts to put in my reports (using Digital Metaphors TppReport). Everything is fine when Display/Scale and Input/Change the size of text, apps and other items is at 100%, but when that number changes, all bets are off: fonts appear incorrectly, and the reports simply do not work. It is frustrating.

I have narrowed part of it down to creating imags from TChart (there are some things happening that I haven't quite figured out).

Take a look at the attached demo: when the setting is 100%:

Image

the caption on the chart caption is the correct size (compare it against the size of the TLabel just above it, which is the same font and text):

Image

but when I change it to 200%, the image is rendered without the correct font size:

Image

The report needs the fonts rendered the font size for printing, not for the display settings.

Demo is attached.

Any suggestions on how to get this to work correctly?

Ed Dressel
Attachments
Image Size.zip
(7.81 KiB) Downloaded 846 times

Ed Dressel
Newbie
Newbie
Posts: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Fri May 11, 2018 2:15 pm

It is quiet, but by far, this is the biggest problem and support issue with our software. Any suggestions on this? Does Steema recognize it as a bug or is there something I can work on?

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

Re: Charts, Images and Display Settings

Post by Yeray » Mon May 14, 2018 8:39 am

Hello,

It looks similar or related to the ticket #1447. I'll take a look at your project and I'll tell you something asap.
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

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

Re: Charts, Images and Display Settings

Post by Yeray » Mon May 14, 2018 10:22 am

Hello,

What TeeChart version are you using?
Fin below my results with TeeChart v2018.24 setting the scale to 150% (I can't set it to 200%).

First I've ran the application and changed the scale "on the fly":
1. onTheFly.png
1. onTheFly.png (19.1 KiB) Viewed 26416 times
This is what I get if I close and reopen the application:
2. reopen.png
2. reopen.png (27.55 KiB) Viewed 26412 times
And this is what I get when I open the application after rebooting at 150%:
3. reboot.png
3. reboot.png (27.67 KiB) Viewed 26411 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: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Mon May 14, 2018 2:42 pm

> What TeeChart version are you using?

v 2018.24 :-)

I did some testing on different computers in the office and am getting differerent results--and non predictable results. My customers are seeing lots of problems with this.

(The high DPI issues are another issue, which, on some computers, create an image that is ~20% of what it should be).

Any suggestions on how to move this forward?

Ed Dressel

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

Re: Charts, Images and Display Settings

Post by Yeray » Thu May 17, 2018 6:59 am

Hello,

We'll check your project in different machines here and compare the results.
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

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

Re: Charts, Images and Display Settings

Post by Yeray » Thu May 17, 2018 12:09 pm

Hello Ed,

I've taken the FontHeightAtDpi function from this guide and added it to TCustomTeePanel.ChangeScale function in TeeProcs.pas to calculate the FontZoom. Could you please check if it gives a better result for you with it?

Code: Select all

{$IFNDEF FMX}
procedure TCustomTeePanel.ChangeScale(M, D: Integer);

  function FontHeightAtDpi(aDPI, aFontSize: integer): integer;
  var tmpCanvas: TCanvas;
  begin
    tmpCanvas := TCanvas.Create;
    try
      tmpCanvas.Handle := GetDC(0);
      tmpCanvas.Font.Assign(self.Font);
      tmpCanvas.Font.PixelsPerInch := aDPI;
      tmpCanvas.Font.Size := aFontSize;
      result := tmpCanvas.TextHeight('0');
    finally
      tmpCanvas.free;
    end;
  end;

var intFontHeightAt96Dpi, intFontHeightCurrent: Integer;
begin
  inherited;

  if M <> D then
  begin
    intFontHeightAt96Dpi:=FontHeightAtDpi(96, Canvas.Font.Size);
    intFontHeightCurrent:=FontHeightAtDpi(Screen.PixelsPerInch, Canvas.Font.Size);

    Canvas.FontZoom:=intFontHeightAt96Dpi/intFontHeightCurrent*100*M/D;
    FView3DOptions.FontZoom:=Round(Canvas.FontZoom);
  end;
end;
{$ENDIF}
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: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Fri May 18, 2018 10:59 pm

Thank you for this code! This seems to work (there are a lot of computers that it needs to be tested on, so I am a bit slow to get too excited)…

**except** when I don't want display setting scaling. This is when I go to print--I create images of the chart for a report, and the fonts and chart get all messed up.

For reports, I use a TChart.TeeCreateMetafile or TChart.TeeCreateBitmap() methods. Is there any way to create an image of a TChart and ignore display settings, so that it prints in a report correctly?

The attached demo is a revision of the early one. If you define "Reporting" at the top defined, it will use Report Builder to create a image in a report, and the font at the top of the report should match the caption of the font (size et al) of the chart.

Ed Dressel
Attachments
Image Size.zip
(8.26 KiB) Downloaded 783 times

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

Re: Charts, Images and Display Settings

Post by Yeray » Tue May 22, 2018 6:45 am

Hello,

To eliminate variables, can the same behaviour be reproduced without Report Builder?
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: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Tue May 22, 2018 10:22 pm

**Finally after years of living wit this bug** I figured out how to recreate the problem without printing, but it was not easy (several hours, including another programmer, just today).

With the attached demo (same as before-but it does have printing features, but won't need that):

1) In the IDE turn off generating a manifest (in Tokyo/Seattle, goo to Project/Options/Application and set Manifest File to "(None)"; similar in Seattle). (Having the auto-generate manifest makes my application unworkable).

2) Build and run the app and view the "Generated Image" tab, which should be showing a bitmap.

3) Now change it from a bitmap to a Metafile. The image is 1/4 the size when viewing 200%.

The image height and width are both the percentage larger as defined by the Display Settings--even though the image is not larger (which, being a metafile, it should not have to be).

Please confirm that you can reproduce this.

Ed Dressel
Attachments
Image Size.zip
(50.93 KiB) Downloaded 821 times

Ed Dressel
Newbie
Newbie
Posts: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Fri May 25, 2018 2:46 pm

I posted this a few days ago and haven't heard anything back. Can you confirm that you can reproduce it? It is a critical issue for my customers.

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

Re: Charts, Images and Display Settings

Post by Yeray » Mon May 28, 2018 7:54 am

Hello,

Indeed I reproduced it, but I'm not sure we'll be able to support scales different to 100% without enabling the Manifest. Note the On[Before/After]MonitorDpiChanged events don't fire and Monitor.PixelsPerInch always returns 96.
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: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Mon May 28, 2018 5:51 pm

Thank you for responding.

Turning on manifests about ruins the GUI in my application.

Also note that a BMP works fine here, it is only the WMF that doesn't work. If it would just create the same WMF as before--it seems it must be reading scaling in one place and not in another.

You stated:
..but I'm not sure we'll be able to support scales different to 100% without enabling the Manifest.

I don't understand what you mean by "scales different to 100%". Also, "I'm not sure"--are you looking into this?

Ed Dressel

Ed Dressel
Newbie
Newbie
Posts: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Fri Jun 01, 2018 2:59 pm

Any comments?

Ed Dressel
Newbie
Newbie
Posts: 28
Joined: Tue Dec 05, 2017 12:00 am

Re: Charts, Images and Display Settings

Post by Ed Dressel » Thu Jun 07, 2018 7:39 pm

Yeray wrote:Indeed I reproduced it, but I'm not sure we'll be able to support scales different to 100% without enabling the Manifest. Note the On[Before/After]MonitorDpiChanged events don't fire and Monitor.PixelsPerInch always returns 96.
But why would the TMetafile image be messed up at all if the system doesn't know about the changes? If it would just create the image that it does for 96 PPI, I would be elated. :D

We have our own custom chart program and the creation of a metafile works just fine. This really is the biggest issue in my product.

Ed Dressel

Post Reply