如何在Image上DrawText任意格式的字及任意对齐方式。
procedure TForm1.Button1Click(Sender: TObject);
var
tmpStr :String;
Rect:TRect;
begin
with Rect do
begin
Left := 0;
Right := textimage.Width;
Top := 0;//textimage.Height div 2;
Bottom :=textimage.Height; //textimage.Height div 2;
end; //SetBkMode(textimage.Canvas.Handle,TRANSPARENT);
SetTextColor(textimage.Canvas.Handle,clRed);
SetBkColor(textimage.Canvas.Handle,clBlack);
//textimage.Canvas.FillRect(textimage.Canvas.ClipRect); //清空画布
tmpStr := ' 中国共产主义青中国共产主义青中国共';
DrawText(textimage.Canvas.Handle,PChar(tmpstr),-1,Rect,DT_VCENTER or DT_WORDBREAK or DT_SINGLELINE);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
textimage.Canvas.Brush.Color := clBlack;
textimage.Canvas.FillRect(textimage.ClientRect);
end;
上面代码是我先将image填充黑色。再在上面画红色的字,不知道怎么无法显示?请高人指教。有谁精通的话加我QQ:879271731 也可以付RMB,帮我完成这一功能!
procedure TForm1.Button1Click(Sender: TObject);
var
tmpStr :String;
Rect:TRect;
begin
with Rect do
begin
Left := 0;
Right := textimage.Width;
Top := 0;//textimage.Height div 2;
Bottom :=textimage.Height; //textimage.Height div 2;
end; //SetBkMode(textimage.Canvas.Handle,TRANSPARENT);
SetTextColor(textimage.Canvas.Handle,clRed);
SetBkColor(textimage.Canvas.Handle,clBlack);
//textimage.Canvas.FillRect(textimage.Canvas.ClipRect); //清空画布
tmpStr := ' 中国共产主义青中国共产主义青中国共';
DrawText(textimage.Canvas.Handle,PChar(tmpstr),-1,Rect,DT_VCENTER or DT_WORDBREAK or DT_SINGLELINE);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
textimage.Canvas.Brush.Color := clBlack;
textimage.Canvas.FillRect(textimage.ClientRect);
end;
上面代码是我先将image填充黑色。再在上面画红色的字,不知道怎么无法显示?请高人指教。有谁精通的话加我QQ:879271731 也可以付RMB,帮我完成这一功能!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货