473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Crop a circle image from a square picture

I have a square picture. I need to draw a circle on it, and everything
outside that circle to be set to a certain color, so the image looks framed

On other words, I want to crop a circle form a rectangular picture

Any hints?
Nov 20 '05 #1
4 13780
If it's a not huge image and it's not an old computer, the
straight forward solution is just to run over the picture
and compare pixel by pixel. Like the pseudocode here:

ry = heightInNbrOfPixels / 2
ry = widthInNbrOfPixels / 2
rSqr = min(heightInNbrOfPixels ,widthInNbrOfPixels) * _
min(heightInNbrOfPixels ,widthInNbrOfPixels)
for y = 1 to heightInNbrOfPixels
for x = 1 to widthInNbrOfPixels
if y*y + x*x > rSqr then _
setPixel(x,y) = white
next x
next y
-----Original Message-----
I have a square picture. I need to draw a circle on it, and everythingoutside that circle to be set to a certain color, so the image looks framed
On other words, I want to crop a circle form a rectangular picture
Any hints?
.

Nov 20 '05 #2
I havent looked, but when you do this on most graphics editors, you can fill
the area outside the circle, have you looked thru the libraries ( you
probably have, but just checking )

OHM

Crirus wrote:
I have a square picture. I need to draw a circle on it, and everything
outside that circle to be set to a certain color, so the image looks
framed

On other words, I want to crop a circle form a rectangular picture

Any hints?

Nov 20 '05 #3
Hi Crirus,

Draw a circle with a very, very wide brush.

Regards,
Fergus
Nov 20 '05 #4
"Andreas Lundgren" <d9****@efd.lth.se> scripsit:
I have a square picture. I need to draw a circle on it,

and everything
outside that circle to be set to a certain color, so the

image looks framed

On other words, I want to crop a circle form a

rectangular picture


Create an appropriate 'Region' from a 'GraphicsPath' and assign it to
the 'Graphics' object's 'Clip' property. Then draw the image onto the
canvas (filled with a solid brush before).

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Doug van Vianen | last post by:
Although I have programmed for several decades I am new to Java. I decided to learn it to create Applets to use in web pages I make as a volunteer in the computer club at a seniors' centre. My...
5
by: Kevin Smith | last post by:
Is there a way to "auto-crop" an image in PIL? I have some PNG images with white backgrounds that I want cropped to show only the non-white portion in the center, but I don't see how I can do...
3
by: Ranman | last post by:
Hi all, I have a simple problem that hopefully has a simple solution, but I have yet to figure it out. In a patient database, I have a physician test order form that populates a report that is...
3
by: ACaunter | last post by:
Hi there, I was wondering if there was a way to crop a peice of an ASP.Net Image, allowing the user to zoom in on only a section of the picture?? any help would be appreciated!! thanks --...
2
by: Andreas Viklund via DotNetMonster.com | last post by:
Hi! I am developing an application in ASP.NET that takes an image, that have been created with a digital camera or camera phone, and processes it, to get data from it. The image taken by the user...
1
by: DMCD | last post by:
I want to allow my program users to: 1. Open a jpg inside of a panel control (PictureBox control inside Panel control ... PictureBox picture set to user's jpg file selection); 2. Zoom in and...
15
by: Baron Samedi | last post by:
Every so often, I see someone wanting to prevent heir images being downloaded and the general consensus is "you can't". Now a friend has asked me to think some more about this, and I think that...
3
by: watashi | last post by:
Hello, I have 3 things to consider here, one is source image, form and picture box. My picture or image on the form must be proportional in size to the original image.This image on form...
1
Thekid
by: Thekid | last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.