mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 10:58:16 +02:00
fpvectorial: Modify wmf reader to return pixels for default rendering multiplier 1.
git-svn-id: trunk@52905 -
This commit is contained in:
parent
ca41291b52
commit
0142f210b1
@ -86,7 +86,7 @@ end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// Set correct dpi for scaling of mapmode MM_TEXT.
|
||||
// Set correct dpi for scaling by wmf reader
|
||||
ScreenDPIX := ScreenInfo.PixelsPerInchX;
|
||||
ScreenDPIY := ScreenInfo.PixelsPerInchY;
|
||||
|
||||
@ -125,8 +125,7 @@ begin
|
||||
PaintImage(page);
|
||||
// Misc
|
||||
Caption := Format('%s - "%s"', [PROGRAM_NAME, AFileName]);
|
||||
// For conversion of the mm returned by the wmf reader to screen pixels
|
||||
ImageInfo.Caption := Format('%.1f mm x %.1f mm', [page.Width, page.Height]);
|
||||
ImageInfo.Caption := Format('%.0f x %.0f', [page.Width, page.Height]);
|
||||
FFileName := AFileName;
|
||||
except
|
||||
on E:Exception do
|
||||
@ -146,8 +145,8 @@ begin
|
||||
exit;
|
||||
|
||||
// For conversion of the mm returned by the wmf reader to screen pixels
|
||||
multiplierX := ScreenInfo.PixelsPerInchX / INCH;
|
||||
multiplierY := ScreenInfo.PixelsPerInchY / INCH;
|
||||
multiplierX := 1.0; //ScreenInfo.PixelsPerInchX / INCH;
|
||||
multiplierY := 1.0; //ScreenInfo.PixelsPerInchY / INCH;
|
||||
|
||||
// Calc image size
|
||||
wimg := round(APage.Width * multiplierX); // image size in pixels
|
||||
@ -171,17 +170,27 @@ begin
|
||||
multiplierX := multiplierX * Scrollbox1.ClientWidth / wimg;
|
||||
multiplierY := multiplierY * Scrollbox1.ClientWidth / wimg;
|
||||
end;
|
||||
end else
|
||||
end else begin
|
||||
bmp.SetSize(wimg, himg);
|
||||
multiplierX := 1.0;
|
||||
multiplierY := 1.0;
|
||||
end;
|
||||
|
||||
bmp.Canvas.Brush.Color := clWindow;
|
||||
bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
|
||||
|
||||
APage.AutoFit(bmp.Canvas, wimg, wimg, wimg, dx, dy, zoom);
|
||||
// APage.AutoFit(bmp.Canvas, wimg, wimg, wimg, dx, dy, zoom);
|
||||
|
||||
if APage.UseTopLeftCoordinates then
|
||||
APage.Render(bmp.Canvas, 0, 0, multiplierX, multiplierY) else
|
||||
APage.Render(bmp.Canvas, 0, himg, multiplierX, -multiplierY);
|
||||
|
||||
{
|
||||
if APage.UseTopLeftCoordinates then
|
||||
APage.Render(bmp.Canvas, dx, dy, zoom, zoom) else
|
||||
APage.Render(bmp.Canvas, dx, himg - dy, zoom, -zoom);
|
||||
}
|
||||
|
||||
{
|
||||
if SameText(ExtractFileExt(FFileName), '.wmf') then
|
||||
APage.Render(bmp.Canvas, dx, dy, zoom, zoom) else
|
||||
|
@ -5850,7 +5850,7 @@ begin
|
||||
|
||||
// Start point of text, rotated around the reference point
|
||||
pt := Point(round(Render_NextText_X), round(curDimY)); // before rotation
|
||||
pt := Rotate2dPoint(pt, refPt, -Phi); // after rotation
|
||||
pt := Rotate2dPoint(pt, refPt, -Phi); // after rotation
|
||||
|
||||
// Paint line
|
||||
if ADoDraw then
|
||||
|
@ -2615,7 +2615,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// <rect width="90" height="90" stroke="green" stroke-width="3" fill="yellow" filter="url(#f1)" />
|
||||
// <rect width="90" height="90" stroke="green" stroke-width="3" fill="yellow" filter="url(#f1)" />
|
||||
function TvSVGVectorialReader.ReadRectFromNode(ANode: TDOMNode;
|
||||
AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
||||
var
|
||||
|
@ -134,8 +134,10 @@ uses
|
||||
|
||||
const
|
||||
INCH2MM = 25.4; // 1 inch = 25.4 mm
|
||||
DEFAULT_SIZE = 100; // size of image if scaling info is not available
|
||||
MM2INCH = 1.0/INCH2MM;
|
||||
DEFAULT_SIZE = 100; // size of image (in mm) if scaling info is not available
|
||||
SIZE_OF_WORD = 2;
|
||||
FPV_UNIT: (fuPX, fuMM) = fuPX;
|
||||
|
||||
type
|
||||
TWMFFont = class
|
||||
@ -1271,33 +1273,34 @@ end;
|
||||
|
||||
procedure TvWMFVectorialReader.CalcScalingFactors(out fx, fy: Double);
|
||||
begin
|
||||
// Convert to pixels
|
||||
case FMapMode of
|
||||
MM_TEXT: // 1 log unit = 1 pixel
|
||||
begin
|
||||
fx := ScreenDpiX * INCH2MM;
|
||||
fy := ScreenDpiY * INCH2MM;
|
||||
fx := 1.0;
|
||||
fy := 1.0;
|
||||
end;
|
||||
MM_LOMETRIC: // 1 log unit = 1/10 mm
|
||||
begin
|
||||
fx := 0.1;
|
||||
fy := 0.1;
|
||||
fx := 0.1 * MM2INCH * ScreenDpiX;
|
||||
fy := 0.1 * MM2INCH * ScreenDpiY;
|
||||
end;
|
||||
MM_HIMETRIC: // 1 log unit = 1/100 mm
|
||||
begin
|
||||
fx := 0.01;
|
||||
fy := 0.01;
|
||||
fx := 0.01 * MM2INCH * ScreenDpiX;
|
||||
fy := 0.01 * MM2INCH * ScreenDpiY;
|
||||
end;
|
||||
MM_LOENGLISH: // 1 log unit = 1/100"
|
||||
begin
|
||||
fx := 0.01 * INCH2MM;
|
||||
fy := fx;
|
||||
fx := 0.01 * ScreenDpiX;
|
||||
fy := 0.01 * ScreenDpiY;
|
||||
end;
|
||||
MM_HIENGLISH: // 1 log unit = 1/1000"
|
||||
begin
|
||||
fx := 0.001 * INCH2MM;
|
||||
fy := fx;
|
||||
fx := 0.001 * ScreenDpiX;
|
||||
fy := 0.001 * ScreenDpiY;
|
||||
end;
|
||||
MM_TWIPS: // 1 log unit = 1 twip
|
||||
MM_TWIPS: // 1 log unit = 1 twip = 1/1440 inch
|
||||
begin
|
||||
fx := 1.0 / 1440 * INCH2MM;
|
||||
fy := fx;
|
||||
@ -1306,19 +1309,30 @@ begin
|
||||
if (FWindowExtent.X = 0) or (FWindowExtent.Y = 0) then
|
||||
exit;
|
||||
if FHasPlaceableMetaHeader then begin
|
||||
FPageWidth := (FBBox.Right - FBBox.Left) * INCH2MM / FUnitsPerInch;
|
||||
FPageHeight := (FBBox.Bottom - FBBox.Top) * INCH2MM / FUnitsPerInch;
|
||||
FPageWidth := (FBBox.Right - FBBox.Left) / FUnitsPerInch * ScreenDpiX;
|
||||
FPageHeight := (FBBox.Bottom - FBBox.Top) / FUnitsPerInch * ScreenDpiY;
|
||||
end else
|
||||
if FWindowExtent.X > FWindowExtent.Y then begin
|
||||
FPageWidth := DEFAULT_SIZE;
|
||||
FPageHeight := DEFAULT_SIZE * FWindowExtent.Y / FWindowExtent.X;
|
||||
FPageWidth := DEFAULT_SIZE * MM2INCH * ScreenDpiX;
|
||||
FPageHeight := FPageWidth * FWindowExtent.Y / FWindowExtent.X;
|
||||
end else begin
|
||||
FPageHeight := DEFAULT_SIZE;
|
||||
FPageWidth := DEFAULT_SIZE * FWindowExtent.X / FWindowExtent.Y;
|
||||
FPageHeight := DEFAULT_SIZE * MM2INCH * ScreenDpiY;
|
||||
FPageWidth := FPageHeight * FWindowExtent.X / FWindowExtent.Y;
|
||||
end;
|
||||
fx := FPageWidth / FWindowExtent.X;
|
||||
fy := FPageHeight / FWindowExtent.Y;
|
||||
end;
|
||||
|
||||
// If required convert to mm
|
||||
// The nominal fpv units are mm, but the svg reader converts to pixels.
|
||||
if FPV_UNIT = fuMM then begin
|
||||
fx := fx / ScreenDpiX * INCH2MM;
|
||||
fy := fy / ScreenDpiY * INCH2MM;
|
||||
if FMapMode in [MM_ISOTROPIC, MM_ANISOTROPIC] then begin
|
||||
FPageWidth := FPageWidth / ScreenDpiX * INCH2MM;
|
||||
FPageHeight := FPageHeight / ScreenDpiY * INCH2MM;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Scale horizontal logical units (x) to millimeters }
|
||||
|
@ -403,13 +403,18 @@ var
|
||||
rec: TWMFBrushRecord;
|
||||
idx: Word;
|
||||
wmfbrush: TWMFBrush;
|
||||
brushstyle: TFPBrushStyle;
|
||||
begin
|
||||
if SameBrush(ABrush, FCurrBrush) then
|
||||
exit;
|
||||
|
||||
idx := FObjList.FindBrush(ABrush);
|
||||
if idx = Word(-1) then begin
|
||||
case ABrush.Style of
|
||||
// No gradient support by wmf --> use a clear brush instead.
|
||||
if ABrush.Kind <> bkSimpleBrush then
|
||||
brushstyle := bsClear else
|
||||
brushstyle := ABrush.Style;
|
||||
case brushstyle of
|
||||
bsClear : rec.Style := BS_NULL;
|
||||
bsSolid : rec.Style := BS_SOLID;
|
||||
bsHorizontal : begin rec.Style := BS_HATCHED; rec.Hatch := HS_HORIZONTAL; end;
|
||||
|
Loading…
Reference in New Issue
Block a user