From: vdata@inforamp.net (Bryan Zarnett)
Newsgroups: comp.lang.pascal
Subject: Transparent Bitblt
Date: Fri, 21 Apr 1995 04:50:11
Organization: Virtual Data Inc.

Since this was a big topic, heres what I did using mask..basically did at least


procedure TForm1.FormPaint(Sender:TObject)
var
        bmpBackground:TBitmap;
        bmpSprite,bmpMask:TBitmap;
        rectClient,rectSprite:TRect;
begin
        {load and place a background bitmap}
        bmpBackground:=TBitmap.Create;
        bmpBackground.LoadFromFile('d:\....');
        Form1.Canvas.Pen.Mode:=pmCopy;
        Form1.Canvas.Draw(10,10,bmpBackground);

        {load the sprite and its mask}
        bmpSprite:=TBitmap.Create;
        bmpMask:=TBitmap.Create;
        bmpSprite.LoadFromFile('D;\...');
        bmpMask.LoadFromFile('D;\...');

        MaskBox.Canvas.Draw(1,1,bmpMask); {paintbox for storage}
        SpriteBox.Canvas.Draw(1,1,bmpSprite);


        {figure out the drawing area}
        rectClient:=rect(70,70,70+bmpSprite.Width,70+bmpSprite.Height);
        rectSprite:=rect(1,1,1+bmpSprite.Width,1+bmpSprite.Height);

        {free some memory}
        bmpSprite.Free;
        bmpMask.Free;

        PaintBox1.Canvas.Copymode:=cmSrcCopy;   {copy background}
        PaintBox1.Canvas.CopyRect(rectClient,Form1.Canvas,rectClient);
        {place down the mask}
        PaintBox1.Canvas.Copymode:=cmSrcAnd'
        PaintBox1.Canvas.CopyRect(rectClient,MaskBox.Canvas,rectSprite);
        {place down the sprite}
        PaintBox1.Canvas.Copymode:=cmSrcPaint;
        PaintBox1.Canvas.CopyRect(rectClient,SpriteBox.Canvas,rectSprite);
end;

- Bryan Zarnett
  vdata@inforamp.net
