Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling an ellipse with an image (OF ANY SIZE)

Status
Not open for further replies.

GR1EVER

Programmer
Mar 6, 2003
23
US
I know you can use CreatePatternBrush to make a bitmap loaded from a file into a pattern that can fill a gdi shape such as an ellipse. I also know that in windows 95 (and 98 although msdn doesnt say so) it will only take the first 8 x 8 pixels if the image is bigger than that.

IS THERE ANY WAy... ANY WAY AT ALL TO BYPASS THIS (at least for 98) AND MAKE IT SO THAT AN IMAGE LARGER THAN 8 x 8 CAN BE USED TO FILL AN ELLIPSE WITH A BITMAP LOADED FROM A FILE????

if not, is there some alternative way to do what i want? (fill in an ellipse with an image loaded from a file)

thank you
 
Actually, can't properly use clipping paths in W98, since W98 doesn't support the Ellipse GDI call as a legitimate path, so you have to revert to a clipping region instead. In VB, it would be something like this (I've not included any of the API declarations):

Dim hdc As Long
Dim hRgn As Long
Dim hdcSource As Long

hdc = Picture1.hdc ' Example is in VB so it happens to be easy to target a picturebox
hdcSource = Picture2.hdc ' Bitmap we are going to fill with is in this DC

hRgn = CreateEllipticRgn(10, 10, 120, 100) ' arbitary choice for size of ellipse
SelectClipRgn hdc, hRgn ' Make it a clipping region

StretchBlt hdc, 10, 10, 110, 90, hdcSource, 0, 0, 110, 90, vbSrcCopy

' Clean up GDI objects
SelectClipRgn hdc, 0&
DeleteObject hRgn

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top