Is it possible to Canvas.Textout and Render is scaled (stretch==true)? lazarus / 39-Graphics ---------------------------------------------------------------------- Ozz_Nixon · 2023-02-15 17:56 I am working on a project where I need to render 5 to 8 telnet sessions like little "view screens". I have all of the code ready... but, it does not work. Could someone help (explain the mistake and makes a working example?). Basically, I create a TImage (640x480) scaled down to div 4, click a toolbar button and mimic a session. In that event, I do: [/code]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  var  w, h: Integer;begin  if ssLeft in Shift then  begin    ReleaseCapture;    Perform(WM_SysCommand, $F012, 0);  end;  Image1.Canvas.Brush.Color:=clBlack;  Image1.Canvas.Font.Color:=clYellow;  Image1.Canvas.Font.Size := 12;  h := Image1.Canvas.Font.Height; // in pixels  Image1.Canvas.TextOut(0, 20 + h, 'Superior');  w := Image1.Canvas.TextWidth('Big')+12;  Image1.Canvas.Font.Color:=clLime;  Image1.Canvas.Font.Size := 6;  h := Image1.Canvas.Font.Height; // in pixels  //Image1.Canvas.Font.Style := Image1.Canvas.Font.Style + [fsBold];  Image1.Canvas.TextOut(W, 20 + h, 'Bulletin Board Software');  The flaw is, it is rendering at 12, and 6 pixels respectively - on the small TImage. Instead of running the code, and rendering scaled. * Or am I using the wrong Component/Canvas? Thanks! Ozz ---------------------------------------------------------------------- KodeZwerg · 2023-02-15 19:49 I do not fully understand yet what you try to do. In most cases I do use a TBitmap (or similar) and draw on that what I want and when done I copy it to a TImage. If you can show on an Image what you want to have when done, it would simplify to help you. ---------------------------------------------------------------------- Ozz_Nixon · 2023-02-17 00:48 Okay Screenshot 1 - is what I am getting with the code in my first post. (I will fix the overlap later)... Screenshot 2 - is what I am trying to achieve. I was able to produce screenshot 2, by doing everything in screenshot 1 - at 640x480, then added a new button that changes the size to "div 4" - to get what I am trying to produce. (Which makes me think I need to do some type of Double Buffering, or Offscreen Paint, Copy, Paste to the scaled one? - And avoid flickering, as this will run all day). ---------------------------------------------------------------------- Thaddy · 2023-02-17 10:10 What you want to achieve needs the font to be scaled in pixels, not points. That means the font needs to have a negative value (pixels) instead of points (positive value). That is the ONLY way to be accurate. Formula's are like this: (Given LOGFONT structure on Windows) Code: [Select]lfHeight := -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); // pixels PointSize := MulDiv(-lfHeight, 72, GetDeviceCaps(hDC, LogPixelsY);// pointsBut note that for high resolution screens you should call GetDeviceCaps first. The above formulae are for Windows only, but may be Lazarus supports it cross-platform. ---------------------------------------------------------------------- KodeZwerg · 2023-02-17 10:45 Thats how I calculate the Size field of font. 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 Round((Abs(GetFontData(AFont.Handle).Height) * 72 / AFont.PixelsPerInch));While AFont is a TFont, crossplatform. ---------------------------------------------------------------------- Ozz_Nixon · 2023-02-17 21:43 Thank you both, however, trying negative canvas.font.size - just resulted in my original output. e.g. Small Image, big Text. From what I have found via other posts - is to create a TImage.Visible:=False - Put my text on it, the BitBlt to a visible TImage2.Stretch:=True, and DoubleBuffers:=True. If I get this way to work, I will contribute the code for anyone else to see/use. Ozz ---------------------------------------------------------------------- KodeZwerg · 2023-02-17 22:36 Since I was not able to watch at your image (all i see is a small black something at topleft corner) I try to show you how I would do. Maybe thats a starting point for you. 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 procedure TForm1.Button1Click(Sender: TObject);var  LBmp: TBitmap;  h: Integer;begin  LBmp := TBitmap.Create;  try    LBmp.Width := Image1.Width;    LBmp.Height := Image1.Height;    LBmp.Canvas.Brush.Color := clBlack;    LBmp.Canvas.FillRect(0, 0, LBmp.Width, LBmp.Height);    LBmp.Canvas.Font := Application.MainForm.Font;    LBmp.Canvas.Font.Size := 12;    LBmp.Canvas.Font.Color := clYellow;    LBmp.Canvas.TextOut(0, 20, 'Superior');    h := LBmp.Canvas.TextHeight('Superior') + 20;    LBmp.Canvas.Font.Size := 6;    LBmp.Canvas.Font.Color := clLime;    LBmp.Canvas.TextOut(0, h, 'Bulletin Board Software');    Image1.Picture.Assign(LBmp);  finally    LBmp.Free;  end;end;