Page 1 of 1

wxPdfDocument - convert pixels to millimeters

Posted: Tue Apr 10, 2018 11:19 pm
by cutecode
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?

Re: wxPdfDocument - convert pixels to millimeters

Posted: Wed Apr 11, 2018 12:35 pm
by utelle
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

Re: wxPdfDocument - convert pixels to millimeters

Posted: Sat Apr 14, 2018 8:02 am
by cutecode
thank you