image as circle

mastiSoft
mastiSoft used Ask the Experts™
Hi, I have an question about what language or technology I can use to do following.
Let say I have an image normally shows as  rectangle with height and width.
I need to transform this image into circle . The same bitmap but not rectangular form but circle form.
Can you suggest what I can use to do this. I program in C#, C++, vb using Visual Studio 2019. If I
need to use another language it is no problem.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer
Do you mean something like a circular picturebox : https://www.youtube.com/watch?v=BVS8sl5QE1M
Eduard GherguArchitect - Coder - Mentor
Hi,

The idea is to create an image mask with transparency in the area that should be visible (the rectangle that you have mentioned about). You can read more about here https://stackoverflow.com/questions/21500040/applying-a-mask-to-a-bitmap-and-generating-a-composite-image-at-runtime
no in this example the image is still the same , only showing in circle frame. Imagine you have an green rectangle with red line on the button of the image. I need to rebuild it into the circle and at the end it will be a green circle with red point in the centre . I hope you understand what I try to do.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I found some examples in internet how it have to go , maybe there is not so nice examples but they give some idea what I try to say.
One of images shows the rectangle and the second the same image as an circle (kind of)
2020-01-15-20_53_28-Window.png
2020-01-15-20_54_13-Window.png
Eduard GherguArchitect - Coder - Mentor
Hi,
Oh, more clear now. You'll actually need a polar transformation of the image. You have here a sample for spherical transformation:
https://www.codeproject.com/articles/18160/spherical-coordinates-in-c
David FavorFractional CTO
Distinguished Expert 2018
Do some research about SVG images, for very fast + lightweight, vector drawn images.
There are numerous transformations to do the rectangle to circle mapping all producing diferent results. Here is one result:
Chess board mapped to a circleThe following paper shows the disk to square and inverse square to disk mappings.
https://arxiv.org/ftp/arxiv/papers/1509/1509.06344.pdf

Since you are dealing with rectangles, your first step can simply transform the rectangle to a square by scaling one of the sides to match the other.

The above paper includes this note:
"There are accompanying presentation slides and C++ implementation of this paper available on these websites:"
http://www.slideshare.net/chamb3rlain/mappings-for-squaring-the-circular-disc
http://squircular.blogspot.com
Depending on the circle / rectangle area ratio, you may need to do some kind of interploation. Some basic ones are Bilinear interpolation and Bicubic interpolation.
This YouTube video is buried in one of the sub-links listed above:
https://www.youtube.com/watch?v=s2XNasRj1PM&feature=youtu.be
It shows some interesting transformations of recognizable square images being slowly morphed into circles.
I found this link that has a Fortran 77 program that provides conformal mapping solutions. I am not up on this math, but thought that maybe the program could help you.
https://www.osti.gov/servlets/purl/4800477
Rect_to_Circle-Conformal_Mapping
Thank you for all answers, but it is still not what I searching for. If you look to images I included to my question you will see why.
The image transforms i that way that bottom part will be the center of the circle and height of it will be the radios of the circle. Maybe I have to look closer to OpenGl to resolve this problem.
Software & Systems Engineer
Then you are not looking for simple square to circle...if i understood the concept of your photo
What you want (i assume) is to wrap your image on a 3d like disc while extruding (kind of) any original image distortions to matching bumps.
Probably it would be useful to share some info on what is the purpose of this "transformation" ...unless is for gaming.
Maybe something like this : http://www.paulsprojects.net/tutorials/simplebump/simplebump.html
thank you , there is something I can work with .

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial