Pixels versus Points lazarus / 39-Graphics ---------------------------------------------------------------------- Dan3468298 · 2020-07-15 21:37 In Lazarus using the LCL (I am currently using Cocoa) I am having trouble finding what metric Laz uses for control dimensions.  Is it Points or Pixels (i.e. Dots)? ---------------------------------------------------------------------- Martin_fr · 2020-07-15 22:00 Left/Top/Width/Height are (should be) in Pixel. But: The Designer stores the PPI (Pixel per Inch) value, for which those measurements where correct. So if you open the form on a device with different PPI then everything will be scaled. ---------------------------------------------------------------------- winni · 2020-07-15 22:18 Hi! Take care with Fonts: Size is Points Height is Pixels Winni ---------------------------------------------------------------------- Dan3468298 · 2020-07-16 11:58 Can Points Per Inch (PPI) always be assumed to be 72? ---------------------------------------------------------------------- rvk · 2020-07-16 12:09 Quote from: Dan3468298 on July 16, 2020, 01:58:15 pmCan Points Per Inch (PPI) always be assumed to be 72? No, you can't assume that. https://www.photoshopessentials.com/essentials/the-72-ppi-web- resolution-myth/ ---------------------------------------------------------------------- Dan3468298 · 2020-07-16 13:08 Thanks! ---------------------------------------------------------------------- Martin_fr · 2020-07-16 14:02 You can disable scaling though, if that is what you want. https://wiki.lazarus.freepascal.org/High_DPI#High_DPI_in_Lazarus_1.8_a nd_above ---------------------------------------------------------------------- Dan3468298 · 2020-07-16 14:48 Is TForm.DesignTimePPI Points Per Inch?  When application is running what property do I use to get current Points Per Inch?  Thanks ---------------------------------------------------------------------- Handoko · 2020-07-16 14:52 Not sure about point. Maybe you can use Monitor.PixelsPerInch function. Higher resolution displays usually have higher PPI. In printer, they usually call it DPI. iPhone 6 Plus has 401 PPI: https://en.wikipedia.org/wiki/Retina_display#Models ---------------------------------------------------------------------- Dan3468298 · 2020-07-16 14:53 Quote from: rvk on July 16, 2020, 02:09:21 pmQuote from: Dan3468298 on July 16, 2020, 01:58:15 pmCan Points Per Inch (PPI) always be assumed to be 72? No, you can't assume that. https://www.photoshopessentials.com/essentials/the-72-ppi-web- resolution-myth/ That article is only about Pixels.  I am wondering about Points https://en.wikipedia.org/wiki/Point_(typography) where DTP defined a Point as 1/72 Inches.  Should I ignore Points and only consider Pixels and the Pixels per Inch because Lazarus only does that? ---------------------------------------------------------------------- skalogryz · 2020-07-16 15:02 On Cocoa widgetset DPI is 96. https://wiki.freepascal.org/Cocoa_DPI There's a special behavior added to draw higher quality images for Retina displays. But overall DPI is assumed to be 96. (even though the native macOS is 72) ---------------------------------------------------------------------- Dan3468298 · 2020-07-16 15:08 Quote from: skalogryz on July 16, 2020, 05:02:38 pmOn Cocoa widgetset DPI is 96. https://wiki.freepascal.org/Cocoa_DPI There's a special behavior added to draw higher quality images for Retina displays. But overall DPI is assumed to be 96. (even though the native macOS is 72) Thanks for pointing this out. ---------------------------------------------------------------------- rvk · 2020-07-16 15:18 Quote from: Dan3468298 on July 16, 2020, 04:53:42 pmQuote from: rvk on July 16, 2020, 02:09:21 pmQuote from: Dan3468298 on July 16, 2020, 01:58:15 pmCan Points Per Inch (PPI) always be assumed to be 72? No, you can't assume that. https://www.photoshopessentials.com/essentials/the-72-ppi-web- resolution-myth/ That article is only about Pixels.  I am wondering about Points https://en.wikipedia.org/wiki/Point_(typography) where DTP defined a Point as 1/72 Inches.  Should I ignore Points and only consider Pixels and the Pixels per Inch because Lazarus only does that? You also take about PPI (which is pixels per inch and not points per inch). Anyway... you can never assume point or dots per inch of 72. For example richedit can have 72 dpi while a printer has 300, 600 or 1200 dpi. It all depends on what you are taking about. ---------------------------------------------------------------------- howardpc · 2020-07-16 15:37 Quote from: Dan3468298 on July 16, 2020, 04:53:42 pmI am wondering about Points https://en.wikipedia.org/wiki/Point_(typography) where DTP defined a Point as 1/72 Inches.  Should I ignore Points and only consider Pixels and the Pixels per Inch because Lazarus only does that? The D in DPI is a "dot". For screens a dot nearly always means a picture element or pixel. Screen pixels vary in size, and are not always square. A pixel refers to an item of hardware, and is not a measurement. Early cathode ray tube screens had pixels whose size was determined by the width of the electron beam that was aimed at a curved glass screen covered in phosphorescent materials. For printers, a "dot" represents a splodge of ink, and the printer resolution determines the smallest splodge the printer can produce. The distance between printer dots or splodges is commonly measured in points, an ancient measurement, predating the computer era. A point is always exactly 1/72 inch. It is a measurement, not a specific item of hardware. ---------------------------------------------------------------------- Dan3468298 · 2020-07-19 14:39 Quote from: skalogryz on July 16, 2020, 05:02:38 pmOn Cocoa widgetset DPI is 96. https://wiki.freepascal.org/Cocoa_DPI There's a special behavior added to draw higher quality images for Retina displays. But overall DPI is assumed to be 96. (even though the native macOS is 72) Shouldn't: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Panel1.Width := Round(96 * 3.5); result in a panel 3.5 inches wide on screen?  If I measure with a ruler, its about 2.68 inches. ---------------------------------------------------------------------- skalogryz · 2020-07-19 15:51 Quote from: Dan3468298 on July 19, 2020, 04:39:48 pmShouldn't: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Panel1.Width := Round(96 * 3.5); result in a panel 3.5 inches wide on screen?  If I measure with a ruler, its about 2.68 inches. For this you have to do the "calibration". No matter what the actual physical size, the system would always report either DPI. Also, I can change a resolution of the screen - DPI stays the same, even though from the real world point of view, the number of pixels stays the same. The "calibration" should provide you the actual width and height of the monitor. (i.e. in inches).  (Another way is to use API to get the physical dimension... but sometimes they might not be reliable) Using this value and the actual screen pixel size - you get your own real-world accurate Pixel Per inches value. As a result you will able to calculate the number of pixels to match the real world pretty easy. I've seen such approach used in real life. The method was used to calibrate tablet (touchscreen) devices. The software was written to adjust to UI components to the physical size (to be useable by human fingers). ---------------------------------------------------------------------- Dan3468298 · 2020-07-19 17:08 By 'calibration', do you mean this is a pascal command?  I can find no reference to it if so.   Furthermore, say if I am not concerned with exact physical measurement on the screen/form, can I assume when I copy panel canvas to printer canvas everything will scale properly and printed output will measure width 3.5 inches?  I am trying to achieve the classic WYSIWYG from screen to printer.  Thx. ---------------------------------------------------------------------- skalogryz · 2020-07-20 02:56 Quote from: Dan3468298 on July 19, 2020, 07:08:49 pmBy 'calibration', do you mean this is a pascal command?no. by 'calibration' i'm referring to acquiring the actual physical size of the display screen. Again, there might an API (pascal command) for that. There might be not. IIRC, on Windows there's no reliable way of getting the screen size. not sure about macOS Quote from: Dan3468298 on July 19, 2020, 07:08:49 pmI am trying to achieve the classic WYSIWYG from screen to printer.For WYSIWG you don't need to know the actual DPI of a monitor. Nor you need you the physical size of the monitor. None of that is needed. All you need is: 1) to maintain proportions 2) use the physical size bound measurements while design Think of a text editor. It allows the text placement and formatting. All of the measurements are done in points with the assumption of classic 72 ppi.  (The other measurements is width of the destination paper, paragraph offets etc.) On the screen these 72 ppi are translated and maintained to match the screen 96 dpi. Since the proportions are the same, you can always see the similar text layout, no matter what the end printer DPI is (300, 600 or else) and whatever the editor ZOOM factor is. (once can zoom, so the 10pt font can look like 96pt font size). But, since! your business is labels ("Label It!" right?) you might want to have the feature as "zoom to real life" in your screen. In order to do that, you might need to prompt the user to measure their screen size and specify the actual length. After that you will be able to calculate the proper pixel size. ---------------------------------------------------------------------- skalogryz · 2020-07-20 03:00 for macOS CGDisplayScreenSize function is available. However, it only return accurate results, if EDID is provided by display. Otherwise the results are inaccurate and the user would need to make a real-life measurements to get accurate results. hmm.... Win MSDN version... hmm ---------------------------------------------------------------------- Dan3468298 · 2020-07-20 12:22 This brings me back to Points.  So fonts on computer are assumed at 72 PPI so a font of size 10 prints at actual 10 point on printer and is scaled to look nice on computer monitor to maintain proportion of font to page.  Thanks! ---------------------------------------------------------------------- lucamar · 2020-07-20 13:18 You should read Wikipedia's articles on Dots per inch and Pixel density. It's all quite well explained there ---------------------------------------------------------------------- Dan3468298 · 2020-07-20 19:59 Thanks. ---------------------------------------------------------------------- kupferstecher · 2020-07-20 22:02 Quote from: Martin_fr on July 16, 2020, 04:02:36 pmYou can disable scaling though, if that is what you want.The designtime dpi scaling should rather be a project setting like the runtime scaling and not an IDE setting.