delphi下怎么给JPG图片添加文字水印
展开全部
unit untImagePaintText;
interface
uses jpeg, Classes, Graphics, SysUtils;
/// <summary>
/// 打开一幅图片(jpg,bmp)在上写入文字
/// </summary>
/// <param name="FilePath">图片路径</param>
/// <param name="X">文字左边距</param>
/// <param name="Y">文字上边距</param>
/// <param name="Texts">写入文字内容</param>
/// <returns>写入是否成功</returns>
function ImagePaintText(FilePath: string; X, Y: Integer; Texts: TStringList): Boolean;
implementation
function JpgToBmp(FilePath: string): string;
var
MyJPEG: TJPEGImage;
MyBMP: TBitmap;
s: string;
begin
Result := '';
s := copy(FilePath, 1, Length(FilePath) - 4) + FormatDateTime('YYYYMMDDhhmmsszzz', Now) + '.bmp';
MyJPEG := TJPEGImage.Create;
with MyJPEG do
begin
LoadFromFile(FilePath);
MyBMP := TBitmap.Create;
with MyBMP do
begin
Width := MyJPEG.Width;
Height := MyJPEG.Height;
Canvas.Draw(0, 0, MyJPEG);
SaveToFile(s);
Result := s;
interface
uses jpeg, Classes, Graphics, SysUtils;
/// <summary>
/// 打开一幅图片(jpg,bmp)在上写入文字
/// </summary>
/// <param name="FilePath">图片路径</param>
/// <param name="X">文字左边距</param>
/// <param name="Y">文字上边距</param>
/// <param name="Texts">写入文字内容</param>
/// <returns>写入是否成功</returns>
function ImagePaintText(FilePath: string; X, Y: Integer; Texts: TStringList): Boolean;
implementation
function JpgToBmp(FilePath: string): string;
var
MyJPEG: TJPEGImage;
MyBMP: TBitmap;
s: string;
begin
Result := '';
s := copy(FilePath, 1, Length(FilePath) - 4) + FormatDateTime('YYYYMMDDhhmmsszzz', Now) + '.bmp';
MyJPEG := TJPEGImage.Create;
with MyJPEG do
begin
LoadFromFile(FilePath);
MyBMP := TBitmap.Create;
with MyBMP do
begin
Width := MyJPEG.Width;
Height := MyJPEG.Height;
Canvas.Draw(0, 0, MyJPEG);
SaveToFile(s);
Result := s;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询