Thanks Nigel,
Here's what I came up with...
procedure PolyPolygonForIE_Voids(aDC: HDC; aPtArr: PPoint; aPtCount: PInteger; aPlyCount: Integer; BrClr: TColor = 0; BrOp: Byte = 255; BmpBrush: Str255 = '');
{ Draw transparent polygons WITH voids using Windows PolyPolygon procedure & TIEBitmap AlphaChannel }
var
TmpCnv: TCanvas;
aBmp: TBitmap;
ieBmp: TIEBitmap;
DrawFormWidth, DrawFormHeight: Integer;
begin
if (aPlyCount = 0) then Exit { Nothing to do }
else if (aPtCount^ < 3) then Exit; { Not a valid polygon }
{ Create temporary canvas from Device Context }
TmpCnv := TCanvas.Create;
TmpCnv.Handle := aDC;
DrawFormWidth := TmpCnv.ClipRect.Right;
DrawFormHeight := TmpCnv.ClipRect.Top;
{ Create Bitmap for Alpha Channel (Mask) }
aBmp := TBitmap.Create;
aBmp.Canvas.Brush.Style := bsSolid;
aBmp.Canvas.Brush.Color := clBlack; { Set color here before width / height }
aBmp.Width := DrawFormWidth;
aBmp.Height := DrawFormHeight;
{ Set brush color to grey value from user-defined opacity value }
aBmp.Canvas.Brush.Color := RGB(BrOp, BrOp, BrOp);
{ Draw polygon with voids using Windows.PolyPolygon (Alpha Image) }
PolyPolygon(aBmp.Canvas.Handle, aPtArr^, aPtCount^, aPlyCount);
{ Create 'ie' bitmap, same size as Device Context }
ieBmp := TIEBitmap.Create(DrawFormWidth, DrawFormHeight, ie32RGB); { This method seems fastest }
{ Set compositing mode }
ieBmp.IECanvas.SetCompositingMode(ieCompositingModeSourceOver, ieCompositingQualityDefault);
{ Assign Mask to ieBmp's Alpha Channel }
ieBmp.AlphaChannel.Assign(aBmp);
ieBmp.SyncAlphaChannel(True);
{ Set brush color to user-defined value }
ieBmp.Canvas.Brush.Color := BrClr;
{ Draw polygon with voids using Windows.PolyPolygon (Source Image) }
PolyPolygon(ieBmp.Canvas.Handle, aPtArr^, aPtCount^, aPlyCount);
{ Merge result onto our DrawForm canvas }
ieBmp.DrawToCanvasWithAlpha(TmpCnv, 0, 0);
aBmp.Free;
ieBmp.Free;
TmpCnv.Free;
end; { PolyPolygonForIE_Voids }
If I want to make ieBmp global and 'recycle' it, how do I go about reassigning the Alpha Channel? I've tried a few things, but I can't get the canvas / alpha channel to reset properly.