mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-12 14:08:33 +02:00
fpvectorial: Adapt wmf reader example to new coordinates.
git-svn-id: trunk@52886 -
This commit is contained in:
parent
523e0080fa
commit
f0ee118264
@ -41,6 +41,7 @@ type
|
|||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
FVec: TvVectorialDocument;
|
FVec: TvVectorialDocument;
|
||||||
|
FFileName: String;
|
||||||
procedure LoadImage(const AFileName: String);
|
procedure LoadImage(const AFileName: String);
|
||||||
procedure PaintImage(APage: TvPage);
|
procedure PaintImage(APage: TvPage);
|
||||||
procedure ReadFromIni;
|
procedure ReadFromIni;
|
||||||
@ -117,12 +118,16 @@ begin
|
|||||||
// Load the image file into a TvVectorialDocument
|
// Load the image file into a TvVectorialDocument
|
||||||
FVec.ReadFromFile(AFilename);
|
FVec.ReadFromFile(AFilename);
|
||||||
// Draw the image
|
// Draw the image
|
||||||
|
FVec.GuessDocumentSize;
|
||||||
page := FVec.GetPage(0);
|
page := FVec.GetPage(0);
|
||||||
|
if (page.Width = 0) or (page.Height = 0) then
|
||||||
|
page.CalculateDocumentSize;
|
||||||
PaintImage(page);
|
PaintImage(page);
|
||||||
// Misc
|
// Misc
|
||||||
Caption := Format('%s - "%s"', [PROGRAM_NAME, AFileName]);
|
Caption := Format('%s - "%s"', [PROGRAM_NAME, AFileName]);
|
||||||
// For conversion of the mm returned by the wmf reader to screen pixels
|
// 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('%.1f mm x %.1f mm', [page.Width, page.Height]);
|
||||||
|
FFileName := AFileName;
|
||||||
except
|
except
|
||||||
on E:Exception do
|
on E:Exception do
|
||||||
MessageDlg(E.Message, mtError, [mbOK], 0);
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
||||||
@ -134,6 +139,8 @@ var
|
|||||||
bmp: TBitmap;
|
bmp: TBitmap;
|
||||||
multiplierX, multiplierY: Double;
|
multiplierX, multiplierY: Double;
|
||||||
wimg, himg: Integer;
|
wimg, himg: Integer;
|
||||||
|
dx, dy: Integer;
|
||||||
|
zoom: Double;
|
||||||
begin
|
begin
|
||||||
if APage = nil then
|
if APage = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -166,9 +173,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
bmp.SetSize(wimg, himg);
|
bmp.SetSize(wimg, himg);
|
||||||
|
|
||||||
bmp.Canvas.Brush.Color := clWindow;
|
bmp.Canvas.Brush.Color := clWindow;
|
||||||
bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
|
bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
|
||||||
APage.Render(bmp.Canvas, 0, 0, multiplierX, multiplierY);
|
|
||||||
|
APage.AutoFit(bmp.Canvas, wimg, wimg, wimg, dx, dy, zoom);
|
||||||
|
|
||||||
|
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
|
||||||
|
APage.Render(bmp.Canvas, dx, himg - dy, zoom, -zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
// APage.Render(bmp.Canvas, 0, 0, multiplierX, multiplierY);
|
||||||
// Assign the bitmap to the image's picture.
|
// Assign the bitmap to the image's picture.
|
||||||
Image1.Picture.Assign(bmp);
|
Image1.Picture.Assign(bmp);
|
||||||
Image1.Width := bmp.Width;
|
Image1.Width := bmp.Width;
|
||||||
|
Loading…
Reference in New Issue
Block a user