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);