wxPdfDocument - convert pixels to millimeters

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
User avatar
cutecode
Earned some good credits
Earned some good credits
Posts: 141
Joined: Fri Dec 09, 2016 7:28 am
Contact:

wxPdfDocument - convert pixels to millimeters

Postby cutecode » Tue Apr 10, 2018 11:19 pm

in function

Code: Select all

wxPdfDocument::Image    (    const wxString &     file,
      double     x,
      double     y,
      double     w = 0,
      double     h = 0,

x,y,w,h - are pixels, but a I want to draw an image using millimeters.

How to convert millimeters to pixels?
regards,
Alexander Saprykin
www.wxwidgets.ru

utelle
Moderator
Moderator
Posts: 782
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument - convert pixels to millimeters

Postby utelle » Wed Apr 11, 2018 12:35 pm

cutecode wrote:in function

Code: Select all

wxPdfDocument::Image    (    const wxString &     file,
      double     x,
      double     y,
      double     w = 0,
      double     h = 0,

x,y,w,h - are pixels

No, that is simply not true. The position, height, and width of the image are given in user units, that is, the unit system selected on creating the wxPdfDocument class instance. The default unit system is millimeters, but centimeters, points or inches are also selectable.

Following a quote from the wxPdfDocument API documentation of the Image method:
wxPdfDocument API wrote:The dimensions can be specified in different ways:

  • explicit width and height (expressed in user unit)
  • one explicit dimension, the other being calculated automatically in order to keep the original proportions
  • no explicit dimension, in which case the image is put at 72 dpi

That is, you can specify the image dimensions (width and height) explicitly, or just width or height, or nothing (leaving it to wxPdfDocument to determine the image size).

cutecode wrote:but a I want to draw an image using millimeters.

How to convert millimeters to pixels?

Usually there is no need to convert image dimensions. Just use the width or height of the image in millimeters you want in the resulting PDF document, and wxPdfDocument will scale it accordingly. However, this only works if you use millimeters as the wxPdfDocument unit system.

Regards,

Ulrich

User avatar
cutecode
Earned some good credits
Earned some good credits
Posts: 141
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: wxPdfDocument - convert pixels to millimeters

Postby cutecode » Sat Apr 14, 2018 8:02 am

thank you
regards,
Alexander Saprykin
www.wxwidgets.ru


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests