Link to home
Start Free TrialLog in
Avatar of JBreits
JBreits

asked on

Transparent parts for Bitmaps in D1

I'm using Delphi 1 and I was wondering if anyone could supply
my with some source code that would show me how to bring
a bitmap onto my form and not display one of the colors in the
bitmap, so that I can see what would normally be hidden
by that color.  It also needs to be done quickly.

Thanks,
JBreits
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is an example... I cahgned the function and a bit of the code...

var
      bmp : TBitmap;
procedure DoTrans(DestForm : TForm; var Bmp : TBitmap; Col : TColor);
var
      x,y : Integer;
begin
      for y := 0 to Bmp.Height - 1 do
            for x := 0 to Bmp.Width - 1 do
                  if Bmp.Canvas.Pixels[x,y] = Col then
                        Bmp.Canvas.Pixels[x,y] := DestForm.Color;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
            DoTrans(Form1, bmp, clBlack);
         Canvas.Draw(100,100, bmp);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
      bmp := TBitmap.Create;
   bmp.LoadFromFile('C:\windows\desktop\wow.bmp');

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
      bmp.Free;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
      Edit1.Text := Format('%d',[Canvas.Pixels[x,y]]);
end;

Hope this helps...

Cheers,
Viktor