Forum > General

drawing on timage canvas

(1/1)

alaa123456789:
hi all ,
why timage color is always black even we change the color in the code to white



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Math, Forms, Controls, Graphics, Dialogs, ExtCtrls,  StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    Image1: TImage;    ScrollBox1: TScrollBox;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  xcenter, ycenter: longint; begin  xcenter:=Image1.Width div 2;  ycenter:=Image1.Height div 2;  with Image1.Canvas do  begin         Brush.Color:=clWhite;         MoveTo(xcenter,ycenter);         Pen.Color:=clGreen;         LineTo(20,20);  end; end;     

jamie:
Set the Picture property width, height ?

and you may need to draw on the picture property because the canvas is just the display surface and most likely will get covered.

alaa123456789:
i found the solution

thanks

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button2Click(Sender: TObject);var  bm: TBitmap;begin  bm := TBitmap.Create;  with bm do  begin    bm.Width := Image1.Width;    bm.Height := Image1.Height;     with Canvas do    begin      Brush.Color := clWhite;      FillRect(ClipRect);       Pen.Width := 3;      Pen.Color := clRed;      MoveTo(10, 10);      LineTo(190, 190);     end;  end;       Image1.Picture.Bitmap := BM;  BM.Free;end;                                

Navigation

[0] Message Index

Go to full version