From: "Joe C. Hecht" Subject: Re: Pixel in a Polygon Date: 29 Mar 1999 00:00:00 GMT Message-ID: <36FFFD9E.601@gte.net> Content-Transfer-Encoding: 7bit References: <7doit8$7fl13@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: Offshore Technology Mime-Version: 1.0 Reply-To: joehecht@gte.net Newsgroups: borland.public.delphi.winapi Harold Holmes wrote: > > Isn't there a way to find out if a certain pixel is within a polygon > region? > > Would need to find out if it is in a polygon, roundrect,rect, circle, > ellipse, etc... as well. Three methods: 1) Create a Windows region (using CreatePolygonRgn or equivelent function), then use PtInRegion(). Easy, but expensive in memory terms. Can be fast is repeat hits are made. 2) Create a monochrome bitmap, and draw the shape in black, and test to see if the pixel at x,y is black. Easy, but expensive in memory terms. Can be fast is repeat hits are made and you access the bitmap data directly. 3) Roll up your sleves and scan convert the y scanline of the shape, and make a ray test of x. Can be very fast, and can have very low memory requirments. Joe -- Joe C. Hecht http://home1.gte.net/joehecht/index.htm