Hejsa!
Jeg har lavet en function, der på baggrund af et bitmap billede fjerner en
bestemt farve:
procedure Form1.MakeTransparent(frm: TForm; img: TImage);
// Create transparent region for window.
// First create non transparent intervals for horizontal line.
// Add it to the scanline region. When scanline done, add
// it to the total non transparent region. Move to next horizontal line.
// When all done, set the total non transparent region to the form
// window region.
var
WindowRgn : hrgn;
SpanRgn : hrgn;
x, y : integer;
spanleft : integer;
trColor : longint;
begin
trColor:=StrToInt64(RGB(0,0,0));
WindowRgn := CreateRectRgn(0,0,0,0);
for y:=1 to frm.Height-1 do
begin
spanleft:=1;
for x:=1 to frm.Width-1 do
if img.Canvas.Pixels[x,y]=trColor then
begin // this pixel shall be invisible
if spanleft < x then
begin
SpanRgn := CreateRectRgn(spanleft,y,x,y+1);
CombineRgn(WindowRgn, WindowRgn, SpanRgn, RGN_OR);
DeleteObject(SpanRgn);
end;
spanleft:=x+1;
end
else // add this pixel to current region
begin
if x = frm.Width-1 then
begin
SpanRgn := CreateRectRgn(spanleft,y,x,y+1);
CombineRgn(WindowRgn, WindowRgn, SpanRgn, RGN_OR);
DeleteObject(SpanRgn);
end;
end;
end;
SetWindowRgn(frm.Handle,WindowRgn,true);
end; // MakeTransparent
Mvh
Nikolaj
http://home11.inet.tele.dk/nikse
PS: I windows 2000 er der en nemmere måde at gøre det på - men den virker
kun på win 2000!