Canvas TextOUT lazarus / 39-Graphics ---------------------------------------------------------------------- Cliff48 · 2015-05-04 10:08 I have a BMP Loaded into a Timage.canvas.  I am trying to write text onto the image using TextOUT.  At the time it is written I see the text flash on the image , so i know I'm writing it correctly to the right place, but the text doesn't stay on the image.  I am sure its something stupid I have overlooked and hopefully more experienced programmers than me can give some clues were to look. Thanks in advance ---------------------------------------------------------------------- Blaazen · 2015-05-04 11:25 There are two canvases in TImage: Image.canvas and Image.Picture.Bitmap.Canvas. The first is canvas just like any other, the second is canvas of loaded picture. ---------------------------------------------------------------------- Cliff48 · 2015-05-04 11:30 Thanks, but i am not sure what that means to me.  I am guessing that I should Textout to the 2nd one? Thx for quick response ---------------------------------------------------------------------- circular · 2015-05-04 11:32 You can textout on the second one, but only once. After loading the picture, or in FormCreate event. It will then stay on the image. ---------------------------------------------------------------------- Cliff48 · 2015-05-04 12:21 Quote from: circular on May 04, 2015, 01:32:27 pmYou can textout on the second one, but only once. After loading the picture, or in FormCreate event. It will then stay on the image. Thanks, but i'm still having problems. With Textout, i am now just getting a rectangular shape in the colour of the windows panel coming yhru my image.  Thats prolly something wrong in the style I am setting.. i guess. Using TextRect, my image disappears and is replaced by the text. I have googled everything i can think of about writing text onto an image and the only references I can find are pointing to other packages.  Surely it cant be that hard to write some text on an image. ---------------------------------------------------------------------- Blaazen · 2015-05-04 12:36 TryCode: [Select]...Canvas.Brush.Style:=bsClear; ---------------------------------------------------------------------- Cliff48 · 2015-05-04 13:25 Quote from: Blaazen on May 04, 2015, 02:36:38 pmTryCode: [Select]...Canvas.Brush.Style:=bsClear; Thanks Blaazen, i do have that. I think i'll just revert to the old days and use some API calls to actually update the BMP image, after all, that is the result I ultimately want. ---------------------------------------------------------------------- Cliff48 · 2015-05-07 20:15 Looking around some more I found a simple solution that works for my needs. load image to a Tbitmap display that image on Timage make change to tbitmap with textout or textrect show changed image in Timage save tbitmap to file. Thanks to those that attempted to help, but didnt understand my question/requirement. ---------------------------------------------------------------------- typo · 2015-05-07 20:49 It seems that there is a problem here, indeed. This code: Code: [Select]with image1.{Picture.Bitmap.}Canvas do   begin     Brush.Style := bsClear;     Font.Color := clBlack;     TextOut(0,0, 'abc');   end;    seems to have different result than this one: Code: [Select]with image1.Picture.Bitmap.Canvas do   begin     Brush.Style := bsClear;     Font.Color := clBlack;     TextOut(0,0, 'abc');   end; ---------------------------------------------------------------------- circular · 2015-05-08 17:43 Well that's not surprising. Image1.Canvas is the window surface, whereas image1.Picture.Bitmap.Canvas is the surface of the bitmap. ---------------------------------------------------------------------- typo · 2015-05-08 18:02 Text is written, but why they are of a different colors? ---------------------------------------------------------------------- Eugene Loza · 2015-05-08 18:42 I often do it in a 'more stupid way'. I use a temporary TJPEG or similar object to load the image into memory and then TCanvas.CopyRect to copy the image to the visible canvas. That leaves me lot's of freedom to scale/zoom, process the image. &Never had any problems with that stuff. ---------------------------------------------------------------------- User137 · 2015-05-08 19:40 Quote from: Cliff48 on May 07, 2015, 10:15:22 pmload image to a Tbitmap display that image on Timage make change to tbitmap with textout or textrect show changed image in Timage save tbitmap to file.For sequence like that, i would use TPicture. Roughly something like: Code: [Select]var pic: TPicture; begin   pic:=TPicture.Create;   pic.LoadFromFile('background.jpg');   // Don't need to load anything if want just single color.   // In those cases set the image size and then fill with color.   pic.Canvas.Font... brush... TextOut...   pic.SaveToFile('saved.jpg');   pic.Free; end; ---------------------------------------------------------------------- circular · 2015-05-08 21:36 Quote from: typo on May 08, 2015, 08:02:20 pmText is written, but why they are of a different colors? Ah ok. Any screenshot?