水印效果怎么在图片里面实现?(100分)

  • 主题发起人 主题发起人 lianzhixin_2004
  • 开始时间 开始时间
L

lianzhixin_2004

Unregistered / Unconfirmed
GUEST, unregistred user!
请教个问题:
如何增加图层,并且在图层实现水印的效果
本人个人理解是水印设置其图层背景的透明度
 
程序实现???你还是用做图软件实现。说得好模糊
 
我的软件要实现设置水印,我做的是个工具软件,在图片导出的时候要有水印的效果,
 
procedure DrawTrans(var dest:TBitmap;destRect :TRECT;source:TBitmap;srcRECT :TRECT;tCl:TColor);
var
tb1,tb2:TBitmap;
R,G,B:Byte;
i,x,y :Integer;
cs,cd:PByteArray;
begin
{初始化}
R:=GetRValue(tcl);
G:=GetGValue(tcl);
B:=getBvalue(tcl);
tb1:=Tbitmap.Create ;
tb2:=Tbitmap.Create ;
tb1.HandleType :=bmDIB;
tb2.HandleType :=bmDIB;
tb1.PixelFormat :=pf24bit;
tb2.PixelFormat :=pf24bit;
{第一步: 变大小,将source中srcRect部分拷贝出来并缩放为 destREct大小
这里为了减小失真采取两步,后截取,后变大小,);
这里有个坐标转换的问题 }
tb1.Width :=srcrect.Right -srcrect.Left;
tb1.Height :=srcrect.Bottom -srcrect.Top;
tb1.canvas.CopyRect(rect(0,0,srcrect.Right -srcrect.Left ,srcrect.Bottom -srcrect.Top),source.Canvas ,srcRect);
tb2.Height :=dest.Height ;
tb2.Width :=dest.Width ;
tb2.Canvas.StretchDraw(destrect,tb1);
tb1.FreeImage ;
tb1.Assign(dest);
{第二步: 复制非透明部分}
tb2.Width :=tb1.Width ;
tb2.Height :=tb1.Height ;
for Y:=0 to tb2.height -1 do
begin
cd:=tb1.ScanLine[Y];
cs:=tb2.ScanLine[Y];
for X:=0 to tb2.Width -1 do
if not(( Abs(cs[X*3]-B)<1) and ( Abs(cs[X*3+1]-G)<1)and( Abs(cs[X*3+2] -R)<1)) then
for I:=0 to 2 do cd[x*3+I]:=cs[x*3+I];
end;
dest.Assign(tb1);
tb1.free;
tb2.free;
end;
 
我写的一个函数,给你参考: 半透明贴图,可以指定完全透明色何透明度。 象photoshop 的图层一样,完全满足你的要求。其中 bmp 就是你的水印

procedure blendDrawBmp(SCanvas: TCanvas; bmp: Tbitmap; Ax,Ay: integer;
TransColor: TColor; BValue: byte);
var
bkBmp: TBitmap;
bkPix: PRGBTriple;
bmpPix: PRGBTriple;
x, y: integer;
begin
bkbmp:=TBitMap.create;
try
bkBmp.Height:=bmp.Height;
bkbmp.Width:=bmp.Width;
bmp.PixelFormat:=pf24Bit;
bkBmp.PixelFormat:=pf24bit;
bkbmp.Canvas.CopyRect(Rect(0,0,bmp.Width,bmp.Height),SCanvas,Rect(Ax,Ay,Ax+bmp.Width,Ay+bmp.Height));
for y:=0 to bmp.Height-1 do
begin
bkPix:=bkBmp.ScanLine[y];
bmppix:=bmp.ScanLine[y];
for x:=0 to bmp.Width-1 do
begin
if Rgb(bmpPix^.rgbtRed, bmpPix^.rgbtGreen, bmpPix^.rgbtBlue)<>TransColor then
begin
bkPix^.rgbtRed:=(bkPix^.rgbtRed*(255-Bvalue)+bmpPix^.rgbtRed * Bvalue) div 255;
bkPix^.rgbtGreen:=(bkPix^.rgbtGreen*(255-Bvalue)+bmpPix^.rgbtGreen * Bvalue) div 255;
bkPix^.rgbtBlue:=(bkPix^.rgbtBlue*(255-Bvalue)+bmpPix^.rgbtBlue * Bvalue) div 255;
end;
Inc(bkPix);
inc(bmpPix);
end;
end;
Scanvas.Draw(Ax,Ay,bkBmp);
finally
bkbmp.free;
end;
end;
 
我还以为不能实现呢?我好好想想!谢谢各位仁兄,小女不才望以后多多指教!
下面的函数可能更加适合一点!高手!我QQ:272978257方便讨论一下吗?
 
数字水印好象是信息隐藏,数据安全里面的吧??
 
我的 QQ; 284039616
 
后退
顶部