ImageEn 给图片添加水印

2020-09-11

//在图像的左下角以30%的不透明度添加水印

bmpImg := TIEBitmap.create;

bmpWM := TIEBitmap.create;

bmpImg.Read('D:\image.jpeg');

bmpWM.Read('D:\Watermark.png');

wmOpacity := 0.30;

bmpWM.RenderToTIEBitmapEx( bmpImg,  

                           0, bmpImg.Height - bmpWM.Height, bmpWM.Width,   bmpWM.Height,

                           0, 0, bmpWM.Width,   bmpWM.Height,

                           True, 255, rfFastLinear, ielNormal,

                           wmOpacity );

bmpImg.Write('D:\image-marked.jpeg');

bmpImg.Free;

bmWM.Free;


// 以不透明度为30%的水印覆盖整个图像(保持宽高比)

bmpImg := TIEBitmap.create;

bmpWM := TIEBitmap.create;

bmpImg.Read('D:\image.jpeg');

bmpWM.Read('D:\Watermark.png');

aRect := GetImageRectWithinArea( wmBMP.Width, wmBMP.Height, bmpImg.Width, bmpImg.Height);

wmOpacity := 0.30;

bmpWM.RenderToTIEBitmapEx( bmpImg,  

                           aRect.Left, aRect.Top, aRect.Right - aRect.Left, aRect.Bottom - aRect.Top,

                           0, 0, bmpWM.Width,   bmpWM.Height,

                           True, 255, rfFastLinear, ielNormal,

                           wmOpacity );

bmpImg.Write('D:\image-marked.jpeg');

bmpImg.Free;

bmWM.Free;


阅读345