Why? What is happening when they are Word? Why Int64 and not Integer?
Auto-scale not working if width > 25. Range check error.
vec.Width := 25; // inch >> scaling: 25.6mm × 100 × width >> 26 would be too big for 65K (Word) >> will be scaled back
See: procedure PrepareScaling(...);
and you'll understand.
Worked the last 16+ hours on this to debug. Now it's working fine. ![Angel O:-)](/Smileys/ExcellentSmileys1/angel.gif)
Thanks for finding this overflow bug (I wonder why fpc does not report it in spite of all checks being active...) But I don't like your solution because making the MaxX and MaxY the largest-possible integers only hides the issue that coordinates may overflow the 16-bit integer range - but wmf is ancient 16-bit technology, coordinates must be within -32768 and 32767.
I (hopefully) fixed the issue by using intermediate floating point variables (because the vec.Width is this type to avoid the Round() here). These intermediate variables now can safely be checked against the allowed maximum value (MAXINT16) and, as in the old code, can be used to reduce the scaling factor so that the real maximum stays below the limit.
Replace the following procedure in wmfVectorialWriter.pas (or use Lazarus trunk), and check whether the bug is fixed this way, too:
procedure TvWMFVectorialWriter.PrepareScaling(APage: TvVectorialPage);
const
MAXINT16 = 32767;
var
maxx, maxy: Double;
begin
FScalingFactor := round(ONE_INCH * 100); // 1 logical unit is 1/100 mm = 10 µm
maxx := APage.Width * FScalingFactor;
maxy := APage.Height * FScalingFactor;
// wmf is 16 bit only! --> reduce magnification if numbers get too big
if Max(maxx, maxy) > MAXINT16 then
begin
FScalingFactor := trunc(MAXINT16 / Max(APage.Width, APage.Height));
FLogicalMaxX := word(trunc(APage.Width * FScalingFactor));
FLogicalMaxY := word(trunc(APage.Height * FScalingFactor));
end else
begin
FLogicalMaxX := trunc(maxx);
FLogicalMaxY := trunc(maxy);
end;
end;