服了你,给不给分随便,PSD的问题你自己搞定 procedure DrawTransparent(var sBmp: TBitMap; dBmp: TBitMap; PosX, PosY: Integer; TranColor: TColor = -1); type PRGBTripleArray = ^TRGBTripleArray; TRGBTripleArray = array[0..32767] of TRGBTriple; function GetSLCOlor(pRGB: TRGBTriple): TColor; begin Result := RGB(pRGB.rgbtRed, pRGB.rgbtGreen, pRGB.rgbtBlue); end; var b, p: PRGBTripleArray; x, y: Integer; BaseColor: TColor; begin sBmp.PixelFormat := pf24Bit; dBmp.PixelFormat := pf24Bit; p := dBmp.scanline[0]; if TranColor = -1 then BaseCOlor := GetSLCOlor(p[0]) else BaseCOlor := TranColor; if (PosY > sBmp.Width) or (PosY > sBmp.Height) then Exit; for y := 0 to dBmp.Height - 1 do begin p := dBmp.scanline[y]; b := sBmp.ScanLine[y + PosY]; for x := 0 to (dBmp.Width - 1) do begin if GetSLCOlor(p[x]) <> BaseCOlor then b[x + PosX] := p[x]; end; end;end;procedure TForm1.Button1Click(Sender: TObject); var bmp:TBitMap; begin bmp:=TBitMap.Create ; bmp.Assign(Image1.Picture); DrawTransparent(bmp,Image2.Picture.Bitmap ,10,10); image1.Picture.Assign(bmp); image1.Refresh ;end;
procedure DrawTransparent(var sBmp: TBitMap; dBmp: TBitMap; PosX, PosY: Integer; TranColor: TColor = -1);
type
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array[0..32767] of TRGBTriple;
function GetSLCOlor(pRGB: TRGBTriple): TColor;
begin
Result := RGB(pRGB.rgbtRed, pRGB.rgbtGreen, pRGB.rgbtBlue);
end;
var
b, p: PRGBTripleArray;
x, y: Integer;
BaseColor: TColor;
begin
sBmp.PixelFormat := pf24Bit;
dBmp.PixelFormat := pf24Bit;
p := dBmp.scanline[0]; if TranColor = -1 then
BaseCOlor := GetSLCOlor(p[0])
else
BaseCOlor := TranColor; if (PosY > sBmp.Width) or (PosY > sBmp.Height) then
Exit; for y := 0 to dBmp.Height - 1 do
begin
p := dBmp.scanline[y];
b := sBmp.ScanLine[y + PosY];
for x := 0 to (dBmp.Width - 1) do
begin
if GetSLCOlor(p[x]) <> BaseCOlor then
b[x + PosX] := p[x];
end;
end;end;procedure TForm1.Button1Click(Sender: TObject);
var
bmp:TBitMap;
begin
bmp:=TBitMap.Create ;
bmp.Assign(Image1.Picture);
DrawTransparent(bmp,Image2.Picture.Bitmap ,10,10);
image1.Picture.Assign(bmp);
image1.Refresh ;end;