首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

GDI+编程,如何在一张图上写字

2012-04-10 
GDI+编程,怎么在一张图上写字?用下面的程序在一张图上写字:(已核对了DrawString的参数,发现和GDIPObJ单元

GDI+编程,怎么在一张图上写字?
用下面的程序在一张图上写字:(已核对了DrawString的参数,发现和GDIPObJ单元中的方法在数量与类型上都符合)
procedure   TfrmMain.Button1Click(Sender:   TObject);
var
    g:   TGPGraphics;
    img:   TGPImage;
    f:   TGPFont;
    brsh,brsh2:TGPSolidBrush;
    ID:   TGUID;
begin
    img:=TGPImage.Create( 'C:\1.jpg ');
    g:=TGPGraphics.Create(img);

    brsh:=TGPSolidBrush.Create(makeColor(255,255,0,0));
    f:=TGPFont.Create( '?? ',10);

    g.DrawString( 'Test ',100,f,GDIPAPI.makePoint(100,100),nil,brsh);
    g.DrawString( 'sText ',-1,f,GDIPAPI.makeRect(0,0,100,100),nil,brsh);

    GetEncoderClsid( 'image/jpeg ',ID);
    Img.Save( 'C:\2.jpg ',ID);
    img.Free;
end;

结果显示:
[Error]   UnitMain.pas(1882):   There   is   no   overloaded   version   of   'DrawString '   that   can   be   called   with   these   arguments
[Error]   UnitMain.pas(1883):   There   is   no   overloaded   version   of   'DrawString '   that   can   be   called   with   these   arguments
请指点?    



[解决办法]
g.DrawString( 'Test ',100,f,MakeRect(30.0, 30.0, 300.0, 200.0),nil,brsh);

热点排行