nanogui: How to draw pixmap with transparency
Subject:
Re: [nanogui] How to draw pixmap with transparency
From:
Julian Smart ####@####.####
Date:
28 Feb 2002 13:47:00 -0000
Message-Id: <4.2.0.58.20020228134222.00a11e60@pop>
At 01:12 PM 2/28/02 +0000, ####@####.#### wrote:
>Hi,
>
>> Thanks, though unfortunately I need to convert the other way around
>> (the wxWindows wxFont constructor takes a font size expressed
>> in points). I may need to set a global fudge factor to get the size
>> right.
>
>Here's how I'm doing the points->pixels conversion:
>
>A "point" is defined as 1/72 inch.
>
>A common screen resolutions is 72 DPI (dots per inch).
>
>So 1 point is 1 pixel at 72 DPI.
>
>If that doesn't look right for your application, try playing with the DPI
>value - maybe increase it to 96 DPI, which gives 1 point = 1.333 pixels.
Thanks a lot! I did try using the 72 dpi, which gave a similar result to
getting the pixels-per-cm from Nano-X.
Regards,
Julian
GR_SCREEN_INFO screenInfo;
GrGetScreenInfo(& screenInfo);
int yPixelsPerCM = screenInfo.ydpcm;
// A point is 1/20 of an inch.
// An inch is 2.541 cm.
// So pixelHeight = (pointSize / 20) (inches) * 2.541 (for cm) * yPixelsPerCM (for pixels)
// I don't know why this is necessary, but otherwise fonts
// are just too big.
float fudgeFactor = 0.6 ;
int pixelHeight = (int) ( (((float)pointSize) / 20.0) * 2.541 * (float) yPixelsPerCM * fudgeFactor) ;
// An alternative: assume that the screen is 72 dpi.
// This gets a similar result to above (pre-fudge factor)
//int pixelHeight = (int) (((float)pointSize / 20.0) * 72.0) ;
--
Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 7EG Tel: +44 (1223) 271063