image上加文字的困惑
在Timage里先添加一个图片,然后分别用下面两个方法在image上写文字。下面那个报错。。这个原理是啥呢?[*]var
[*]MyCanvas1 : TControlCanvas;
[*]Begin
[*]MyCanvas1:=TControlCanvas.Create;
[*]try
[*] Mycanvas1.control:=img1;
[*] 、、 MyCanvas1.StretchDraw(img1.clientRect,img1.Picture.Bitmap);
[*]
[*]
[*] MyCanvas1.Brush.Style :=bsClear;
[*] MyCanvas1.Textout(40,60,'这里添加文字');
[*]finally
[*] MyCanvas1.Free;
[*]end;
[*]end;
begin
Str:='中国';
//Image1.Canvas.Brush.Color:=clred;
Image1.Canvas.Font.Color:=clred;
Image1.Canvas.Font.Name:='宋体';
Image1.Canvas.Font.Style:=;
Image1.Canvas.Font.Size:=36;
X :=(image1.Width - image1.Canvas.TextWidth(str)) div 2;
Y :=(image1.Height - image1.Canvas.TextHeight(str)) div 2;
image1.Canvas.TextOut(X, Y, str);
end;
逛一逛,瞧一瞧,顶一顶,没坏处
页:
[1]