Re: Drawing to scale and display properties
Re: Drawing to scale and display properties
- Subject: Re: Drawing to scale and display properties
- From: Robert Tillyard <email@hidden>
- Date: Tue, 6 Sep 2005 00:15:24 +0100
On 4 Sep 2005, at 05:40, Mike Paquette wrote:
On Sep 3, 2005, at 4:44 PM, Robert Tillyard wrote:
I'm trying to draw data from a GPS device but my routes are
squished as 10 vertical pixels are not the same as 10 horizontal
pixels.
Are there any system calls I can make in my NSView drawRect to
query the display and find out how to scale my drawing to make it
correct both horizontally and vertically?
Thanks, Regards, Rob.
/*
* Returns the size of the specified display in millimeters.
*
* If 'display' is not a valid display ID, the size returned has a
width and height of 0.
*
* If EDID data for the display device is not available, the size
is estimated based on
* the device width and height in pixels from CGDisplayBounds(),
with an assumed resolution
* of 2.835 pixels/mm, or 72 DPI, a reasonable guess for displays
predating EDID support.
*/
CGSize CGDisplayScreenSize(CGDirectDisplayID display)
AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
The CGDirectDisplayID can be obtained from the NSScreen device
dictionary returned by - deviceDescription. Use the key
@"NSScreenNumber" to get the NSNumber holding the
CGDirectDisplayID, and extract the CGDirectDisplayID using
NSNumber's -unsignedIntValue method.
Use this in conjunction with NSScreen's -frame method to obtain the
pixel size of the screen.
Thanks, I can now get the details I though would help me.
Through overlaying my track onto a map from Route 66 I know that the
vertical scale needs to be multiplied by 1.4 to work but this is hard
coded and will not necessarily work on a different display.
My 17" powerbook returns 370 x 230mm in 1440 x 900. Hoiz is 3.89
pixels per mm and vertical is 3.91. This gives me a ratio of 1.005.
I don't seem to be able to calculate the scale I need.
Thanks for your help, Regards, Rob.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden