Board index » delphi » Clipping

Clipping

This must be a stupid question:

I want to clip while drawing inside a canvas, but the TCanvas.Cliprect
property is read-only.

I'm drawing into the canvas of a TBitMap created at runtime, then copying
(using Canvas.Draw) the image into a TPaintBox.Canvas.  I need the bitmap to
have the same dimensions as the paintbox canvas, but I only want the
graphics entities to show up on a subset of the region.

How can I do this?

Thanks,

John Godshall

 

Re:Clipping


John -

Definitely not a stupid question, but this may be a stupid answer. If
you need to create an irregular shape in which to draw, you'll need to
go back to the Windows API, create the region, and then use the
destination's Canvas.Handle property (an HDC) to put it into effect.

But unless this region is really complex, it might be easier to do
multiple CopyRect calls.

Good luck.

Kurt

Re:Clipping


Quote
John Godshall wrote:

> This must be a stupid question:

> I want to clip while drawing inside a canvas, but the TCanvas.Cliprect
> property is read-only.

> I'm drawing into the canvas of a TBitMap created at runtime, then copying
> (using Canvas.Draw) the image into a TPaintBox.Canvas.  I need the bitmap to
> have the same dimensions as the paintbox canvas, but I only want the
> graphics entities to show up on a subset of the region.

> How can I do this?

> Thanks,

> John Godshall

Take a look at the IntersectClipRect API call.

John

Other Threads