Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Given a rectangular or square based image, how do I render it on a window so that the image fit into a circle or ellipse of my own choice?

What I have tried:

I have googled fora solution but was unable to find any.
Posted
Updated 2-May-16 20:20pm
Comments
Sergey Alexandrovich Kryukov 2-May-16 20:04pm    
Not clear. Do you want to distort the image into an ellipse, or you just want to cut out (make transparent) all parts beyond the ellipse? In both cases, what's the problem?

And please pay attention: you have 306 questions by now (!); and I'm sure that many have been removed due to some abuse reports. And still, you have no clue how to ask questions. Are you ignoring all comments. I wonder, how many time you got the note that you have to show What have you tried so far? How many times people try to explain to you that problems are not solved by googling, but you need to read the documentation and write code?

—SA
Ravi Bhavnani 3-May-16 0:16am    
What you want to do is draw the image in a clipped region. This article and Googling for "win32 draw image" should be more than enough to help you meet your goal:

A Guide to WIN32 Clipping Regions
http://www.codeproject.com/Articles/2095/A-Guide-to-WIN32-Clipping-Regions

/ravi
Gbenbam 3-May-16 2:58am    
I don't want to distort the image.I want to cut out all parts outside the ellipse.

1 solution

If you want to draw only parts of the image you must draw only these parts. With somemath you can detect whether a coordinate and its pixel belomg to our drawing region.

Another way is to work with regions. Take a dive into the article A Region Creator.

My tip is to stick with regions, because Microsoft has some functionality built into Windows.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900