Canvas - Drawing in mm lazarus / 39-Graphics ---------------------------------------------------------------------- celso · 2012-11-22 19:13 I´m trying to draw a grid on the screen, but using mm as a unit of measure. I´d read that it depends on the screen resolution, but I didn´t find any example on how to do it. My code to draw the grid is: Code: [Select]    Bitmap.Height := Height;     Bitmap.Width  := Width;     // Drawing the background     Bitmap.Canvas.Pen.Color := clWhite;     Bitmap.Canvas.Rectangle(0, 0, Width, Height);     // Drawing the grid     Bitmap.Canvas.Pen.Color := RGBToColor(243,243,243);     for x:= 1 to (Width div 10) do         for y:= 1 to (Height div 10) do             Bitmap.Canvas.Rectangle( round((x-1)*10),round((y-1)*10),                                      round(x*10),round(y*10));    the grid draw lines with 10 of distance, I want to draw with 10mm of distance. Thanks! ---------------------------------------------------------------------- Blaazen · 2012-11-22 19:26 Forms have the property PixelsPerInch (96 in my case). One inch is 25,4 mm. So you should calculate: Distance := 10 * ppi / 25,4 (which is here ~ 38 px / 10mm) But my laptop LCD (15.6") is 332 mm wide and has horizontally 1680 pixels. It results to ~50 px / 10mm. It is > 20% difference.  If you need exact value you will have to tune your program for each LCD / monitor. ---------------------------------------------------------------------- celso · 2012-11-22 20:03 I used your suggestion, but I got a PPI, of the screen: Code: [Select]xmm := 10 * ScreenInfo.PixelsPerInchX / 25.4; ymm := 10 * ScreenInfo.PixelsPerInchY / 25.4;  then I used these values as increment in x and y. Looks Ok, I´ll do some other tests. But, thanks for the answer!