News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

pixel ratio in logical units X / Y

Started by caraveiro, March 22, 2013, 03:04:10 AM

Previous topic - Next topic

caraveiro

Mean while on earth...


I'm trying to convert the X/Y ratio of a rectangle in pixels (MM_TEXT).
I want to draw in the window, for example, a perfect square and update the pixel size in a status bar.

I'm drawing with this:
Invoke SetMapMode, hdc, MM_ISOTROPIC
Invoke SetWindowExtEx,hdc, 32767, 32767, NULL
Invoke SetViewportExtEx,hdc,cxClient,-cyClient, NULL
Invoke SetViewportOrgEx,hdc,0,cyClient, NULL

But this only allow me to scaled axes while preserving equal logical units on the two axes, ergo a perfect square: x=100,Y=100


But once drawed, I lost how to convert MM_ISOTROPIC's units to MM_TEXT's units pixels.

So the status bar can show the real square unit: DLUs,Pixels, mm or inch

Any clues?

Best regards.
"knowledge is now free at last, everything should be free from now on, enjoy knowledge and life and work for everybody else"
+ORC

qWord

If I'm not wrong, you can use the function LPtoDP() for the edge points of the rectangle to get the number of vertical and horizontal pixels.
Once having this numbers, you can use GetDeviceCaps(GetDC(0),LOGPIXELSX/Y) to calculate the values in inch and mm screen.
MREAL macros - when you need floating point arithmetic while assembling!

caraveiro

Quote from: qWord on March 22, 2013, 06:44:13 AM
If I'm not wrong, you can use the function LPtoDP() for the edge points of the rectangle to get the number of vertical and horizontal pixels.
Once having this numbers, you can use GetDeviceCaps(GetDC(0),LOGPIXELSX/Y) to calculate the values in inch and mm screen.

Good tip, qWord, I'll use the GetDeviceCaps for the mm and inch convertion.

Also I'd found this reference:

Picture Aspect Ratio
Pixel aspect ratio essentials

Pixel Aspect Ratio for VIDEO: The PAR defines the shape of the pixels in an image. Square pixels have an aspect ratio of 1:1. Any other aspect ratio describes a non-square pixel. For example, NTSC television uses a 10:11 PAR. Assuming that you are presenting the video on a computer monitor, the display will have square pixels (1:1 PAR).

I just close to get the formula for the Pixel Aspect Ratio (PAR) of the Screen Resolution fo MM_TEXT mode.


"knowledge is now free at last, everything should be free from now on, enjoy knowledge and life and work for everybody else"
+ORC