Examples Delphi

1) use TBitmap do draw on the canvas, this makes it really easy
2) set it to transparent
3) define the transparent color (if you forget this, the color of the pixel in the bottom left corner will be used):

var
myBitmap : TBitmap;
//..
begin
// somehow create myBitmap
myBitmap.Transparent := true;
myBitmap.TransparentColor := clBlack;
end;