Challenge: How do you determine the physical dimensions of your pixels/monitor?
-
Challenge: How do you determine the physical dimensions of your pixels/monitor? There must be a smart way of determining the real size of a pixel, or at least figuring out the width:height ratio! I can't believe that information has not been stored with the video driver but unfortunately it seems to be the case. Does anyone know of some clever way to work out the physical monitor view dimensions? Implicitly this could mean working out the real pixel size, pixel ratio, pixels per inch... I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? There's a huge prize waiting for you if you accept and solve this quiz/challenge... Well, not really, but I'd be very grateful! :) And measuring the screen by hand does not count! :) /Tommy
-
Challenge: How do you determine the physical dimensions of your pixels/monitor? There must be a smart way of determining the real size of a pixel, or at least figuring out the width:height ratio! I can't believe that information has not been stored with the video driver but unfortunately it seems to be the case. Does anyone know of some clever way to work out the physical monitor view dimensions? Implicitly this could mean working out the real pixel size, pixel ratio, pixels per inch... I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? There's a huge prize waiting for you if you accept and solve this quiz/challenge... Well, not really, but I'd be very grateful! :) And measuring the screen by hand does not count! :) /Tommy
Try these functions:
void MyFunc(CDC* pDC)
{
int logx = pDC->GetDeviceCaps(LOGPIXELSX);
int logy = pDC->GetDeviceCaps(LOGPIXELSY);int nMM = 100;
int nPixelsX = MmToPixels(nMM, logx);
int nPixelsY = MmToPixels(nMM, logy);
}//----------------------------------------------------------------------------/
int MmToPixels(int mm, int LogPixels) // converts mm to pixels
{
return ((int)((long)mm * LogPixels / 25.4));
}//----------------------------------------------------------------------------/
int PixelsToMm(int Pixels, int LogPixels)
{
return (int)(Pixels * 25.4 / LogPixels);
}"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-
Challenge: How do you determine the physical dimensions of your pixels/monitor? There must be a smart way of determining the real size of a pixel, or at least figuring out the width:height ratio! I can't believe that information has not been stored with the video driver but unfortunately it seems to be the case. Does anyone know of some clever way to work out the physical monitor view dimensions? Implicitly this could mean working out the real pixel size, pixel ratio, pixels per inch... I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? There's a huge prize waiting for you if you accept and solve this quiz/challenge... Well, not really, but I'd be very grateful! :) And measuring the screen by hand does not count! :) /Tommy
I don't think you can get 'real' sizes. The way to calculate pixel ratio and draw rulers with inches/centimeters is to use GetDeviceCaps with LOGPIXELSX/LOGPIXELSY. I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? Probably it's because video driver doesn't care if monitor has 15 or 49 inches :-D And imagine a CRT projector connected to your graphics card which displays an image on the wall. In this case, these values would depend on the distance between the device and the wall ;) Your machine would have to be equipped with some sonar system. :) Tomasz Sowinski -- http://www.shooltz.com
-
Challenge: How do you determine the physical dimensions of your pixels/monitor? There must be a smart way of determining the real size of a pixel, or at least figuring out the width:height ratio! I can't believe that information has not been stored with the video driver but unfortunately it seems to be the case. Does anyone know of some clever way to work out the physical monitor view dimensions? Implicitly this could mean working out the real pixel size, pixel ratio, pixels per inch... I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? There's a huge prize waiting for you if you accept and solve this quiz/challenge... Well, not really, but I'd be very grateful! :) And measuring the screen by hand does not count! :) /Tommy
To determine the "viewable area", get the horizontal and vertical resolution windows is currently set to, and convert those pixel values to millimeters (using the PixelsToMm function). If you need it in inches, it is a simple matter to convert mm to inches, and there you have it. "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-
I don't think you can get 'real' sizes. The way to calculate pixel ratio and draw rulers with inches/centimeters is to use GetDeviceCaps with LOGPIXELSX/LOGPIXELSY. I know there's information to retrieve using GetDeviceCaps but they are for some strange reason fix values. They don't change!!! Why is that? Probably it's because video driver doesn't care if monitor has 15 or 49 inches :-D And imagine a CRT projector connected to your graphics card which displays an image on the wall. In this case, these values would depend on the distance between the device and the wall ;) Your machine would have to be equipped with some sonar system. :) Tomasz Sowinski -- http://www.shooltz.com
Ok, that's what I thought... But are you saying that you can create rulers in inches/centimeters using the LOGPIXELSX/Y? Ok, you can create them but they will not reflect the real size on screen right? Intuitively it feels like there's a solution to this... just gotta get someone to find it! :) /T
-
Ok, that's what I thought... But are you saying that you can create rulers in inches/centimeters using the LOGPIXELSX/Y? Ok, you can create them but they will not reflect the real size on screen right? Intuitively it feels like there's a solution to this... just gotta get someone to find it! :) /T
Ok, you can create them but they will not reflect the real size on screen right? Exactly. That's why the parameters you pass to GetDeviceCaps are called 'logical' pixels, not 'real' pixels. One more reason for that: you have controls in your monitor for adjusting the width and height of actual picture displayed on the screen - your graphic card is of course unaware of these adjustments. If you find any program that draws rulers using *real* centimeters/inches, let me know :-D Tomasz Sowinski -- http://www.shooltz.com
-
To determine the "viewable area", get the horizontal and vertical resolution windows is currently set to, and convert those pixel values to millimeters (using the PixelsToMm function). If you need it in inches, it is a simple matter to convert mm to inches, and there you have it. "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Well, I appreciate your help, but the result is not real size... For instance, GetDeviceCaps(LOGPIXELSX/Y) returns a value that is fixed and doesn't depend on any physical settings made on the monitor or even changes made in resolution and physical monitor size. If it would, then everything would have been fine. Try for your self and measure your screen. /T