View Issue Details

IDProjectCategoryView StatusLast Update
0002537JEDI VCL00 JVCL Componentspublic2005-04-12 07:24
ReporteranonymousAssigned Toobones 
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.10 
Summary0002537: JvgRuler does not show correct units
Description
In pixel mode, it's fine.
In centimeter mode, it's fine.
In inches mode, there's a problem. Based on what I see on the screen, it looks like a simple error in the formula. When showing inches, it appears to be multiplying the cm. value instead of dividing it.

The correct setting should be: inches := cm / 2.54
Right now it appears to be set for: inches := cm * 2.54

I'm using 3.00 RC1
TagsNo tags attached.

Activities

user72

2005-01-22 00:06

  ~0006240

Sounds reasonable. After all, one inch == 2.54 cm (approx.)

obones

2005-01-22 06:21

administrator   ~0006249

I've insvestigated this, and it seems the whole formula is wrong. It gets the Pixels Per Inch value for the screen, and then for an unknown reason multiplies it by 1.541 and divides it by 10. I have no idea why that is, as it should directly use the value from the system without adjustments.
After all, if there are 96 pixels per inch, then a ruler of 192 pixels should show 2 inches and not 25 !
I propose to change, in run\JvgUtils the following functions, starting at line 302, by the following code:

function InchesToPixels(DC: HDC; Value: Single; IsHorizontal: Boolean): Integer;
const
  LogPixels: array [Boolean] of Integer = (LOGPIXELSY, LOGPIXELSX);
begin
  Result := Round(Value * GetDeviceCaps(DC, LogPixels[IsHorizontal]));
end;

function CentimetersToPixels(DC: HDC; Value: Single; IsHorizontal: Boolean): Integer;
const
  LogPixels: array [Boolean] of Integer = (LOGPIXELSY, LOGPIXELSX);
begin
  Result := Round(Value * GetDeviceCaps(DC, LogPixels[IsHorizontal])/2.54);
end;


With this, the ruler seems to be much more logical to me.
Could anyone confirm this is alright, so that I can commit those changes?

obones

2005-04-12 07:24

administrator   ~0006960

Well, this is in CVS and since no one complained about it, I'll assume it is resolved.

Issue History

Date Modified Username Field Change
2005-01-21 17:35 anonymous New Issue
2005-01-22 00:06 user72 Note Added: 0006240
2005-01-22 06:21 obones Note Added: 0006249
2005-01-22 06:21 obones Assigned To => obones
2005-01-22 06:21 obones Status new => feedback
2005-04-12 07:24 obones Status feedback => resolved
2005-04-12 07:24 obones Resolution open => fixed
2005-04-12 07:24 obones Note Added: 0006960