Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Display device DPI

From: atruter:hih:au at: 22-Oct-2002 16:41

Hi Brett,
> I'm not entirely clear what your goal is. If it is important that on
screen
> image is very accurate then you probably need a different application
from a
> word processor to render it properly.
My goal is to generate reports, which include images, that can be viewed, edited and printed via a simple WYSIWYG editor. PDF is good, but read only, and MS formats are obscure to say the least. HTML does not let you control page breaks, so I have been looking at XML file format editors. The "problem" is fairly simple to demonstrate. Use the following code to generate a 100x100 png: save/png %test.png to-image layout [origin 0 btn yellow 100x100 100x100 font [size: 18]] Open a word-processor of your choice and insert this image. Look at the properties of the image and note the dimensions (usually given in cm's or inches). Do the same thing on an alternate display device (eg. an LCD) and note how the same image has different dimensions. Changing the printer or screen resolution does not effect this, it seems to be a property of the display device itself (dot pitch?). The practical consequence of this is that the above image saved (using one type of display device) will appear pixelated on another. I found this out the hard way after comparing documentation (screen-shots) written on a 17" CRT (at 1024x768) and viewed on a 15" LCD (also at 1024x768).
> Alternatively maybe you can arrange it > so that your documents with images are always viewed at 100% and ensure
that
> your images do not need scaling in this situation (Ie prescale them).
Exactly what I am trying to do, using code like: ; create a 6"x6" image from a "larger" image DPI: 120 ; 96 for LCD, 100? for a notebook image-size: to-pair (DPI * 6 DPI * 6) save/png bin to-image layout [origin 0 image image-size %1.jpg effect [crop 500x0 800x800]] This works great so long as: a) you don't generate the report on a CRT then view it on an LCD (or vice versa) b) you can work out what the DPI should be This last step is easy enough. On my CRT here I load the 100x100 image from before and observe that its dimensions are 2.11cm. (2.54 / 2.11) * 100 120 DPI. Doing the same thing on an LCD yields 96DPI and a notebook yields 100DPI. Changing the screen res or printer does not seem to effect this. The real answer is to use vector graphics. In the meantime, these apps (AbiWord, MS*Word, etc) are using *something* to say "these here 100 pixels equate to x centimetres (or inches) on this here display device". I just want to access the same "magic number" these boys use! ;) Regards, Ashley