I am sure it is easy, but cannot find anyone who has an answer. I have an image and I need to cut out a circle or even other shapes from this image. I need this code in .net C #. I do this in a class, so this is not wpf or winform. I will need to pass x and y pos and the size of the circle.
Another option is AForge, ImageStatistics. I need to get a circle (part of the image) and get StdDev.
Thanks for the help. Andrew
- update the message chris.
Here is the chris post in C #. Not as pure as his, but his beginning.
public System.Drawing.Image x(string sourceFile, int circleUpperLeftX, int circleUpperLeftY, int circleDiameter) { Bitmap SourceImage = new Bitmap(System.Drawing.Image.FromFile(sourceFile)); Rectangle CropRect = new Rectangle(circleUpperLeftX, circleUpperLeftY, circleDiameter, circleDiameter); Bitmap CroppedImage = SourceImage.Clone(CropRect, SourceImage.PixelFormat); TextureBrush TB = new TextureBrush(CroppedImage); Bitmap FinalImage = new Bitmap(circleDiameter, circleDiameter); Graphics G = Graphics.FromImage(FinalImage); G.FillEllipse(TB, 0, 0, circleDiameter, circleDiameter); return FinalImage; }
source share