• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to convert pixels to centimeters in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to convert pixels to centimeters in Cocoa


  • Subject: How to convert pixels to centimeters in Cocoa
  • From: "Ewan Delanoy" <email@hidden>
  • Date: Tue, 8 May 2007 11:33:22 +0200 (CEST)
  • Importance: Normal

     Hello all,

  for my Cocoa text-editor I need to convert pixels to
centimeters in some place. When I googled "convert pixels
centimeters" or "convert pixels centimeters Cocoa" I found out
how to do this for many other operating systems, but not for
Cocoa in Mac OS X. I guess i just missed the right place
to look...

  For a given Mac machine it is not difficult to make a separate
evaluation of the proportionality constant (e.g, in TextEdit, compare
the length displayed in the tooltips in the "Page Layout" menu item
with the value of [[NSPrintInfo sharedPrintInfo] paperSize] in gdb.

 But for portability, is there a Mac machine-independent
way to do this, something like :

float proportionalityConstantBetweenPixelsAndCentimeters(void)
{
   static float proportionalityConstant=(-1);`
   if (proportionalityConstant<0)  {
   NSPrintInfo* pi=[NSPrintInfo
         standardPrintInfoWithRegisteredPaperName:@"A4"];
   // The width of an A4 sheet is 20.99 centimeters
     proportionalityConstant=([pi paperSize].width)/20.99;
    }
    return proportionalityConstant;
}

   The problem, of course, is that
standardPrintInfoWithRegisteredPaperName: does not exist ...
  Any suggestions ?

                                                                         Ewan




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Does Core Data have a serious problem?
  • Next by Date: Re: initWithHTML Memory leak
  • Previous by thread: SOLVED: Issues with Core Data, NSTreeController, and observedObject
  • Next by thread: Re: How to convert pixels to centimeters in Cocoa
  • Index(es):
    • Date
    • Thread