Re: Make edges smooth after cliping.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Clipping and drawing are two different principles.

Drawing that uses antialiasing attempts to hide the alias effects of the basic pixel resolution of the output device by drawing on pixels that are outside of the shape and creating an average colour containing a mix of the origianal and new colours. The result is that the result appears to be better but is in fact not a true representation.

Clipping on the other hand, is a mechanical process of including or excluding pixels from a certain area. The clip boundary falls on the pixel boundaries and so the pixel cannot be antialiased.

Try filling a path with a brush created from the image.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





danila.benhur@xxxxxxxxx wrote:
Greeting!

I'm using the following code.

// Create graphics path represented by rectangle with rounded angles
GraphicsPath roundedRectangle = this.GetRoundedRectPath(rect, 13);
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
// Set clipping region
g.Clip = new Region(roundedRectangle);
// Draw loaded previously image
g.DrawImage(bmp, 10, 10);

After this code execution i get clipped image. It is clipped with
rectangle with rounded angles. But i have a problem: edges of the
clipped image is rough. Is there any possibility to make the edges of
clipped image smooth?

I really appreciate Your help and thanks in advance.

.



Relevant Pages

  • Re: How to store relative position
    ... drawing area out 50%, and I paint a dot, then zoom the drawing ... For example, if your drawing area is meant to represent a full US Letter Size page then it treats the displayed drawing area as being 8.5 units wide and 11 units high at all times, regardless of the current physically displayed pixel width and height. ... That is exactly how the VB will treat your PictureBox drawing area if you ignore its current physically displayed size and set its ScaleWidth to 8.5 and its ScaleHeight to 11, as has already been suggsted to you by a number of people who have posted reponses to your question. ...
    (microsoft.public.vb.general.discussion)
  • Re: CDC problem
    ... GDI+ although it would support float has to round it of to the nearest pixel ... There is no concept of float pixel or partial whatever library we choose. ... >> I am using CDC member functionsfor drawing ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Problem with vista and form appearance
    ... When drawing single pixel thickness lines then the final pixel of the line is not actually plotted. ... This applies both when drawing using the native VB Line method and when drawing using the alternative API LineTo method. ... Again this behaviour is by design, and one of the reasons for it is so that continuous lines which are drawn by repeatedly using the Line method to draw from the end of the previous line to some new position, etc, etc all get drawn properly. ... The rationale behind it is to prevent the last pixel of each line segment being plotted twice, once as the last pixel of the first line segment and once again as the first pixel of the following line segment. ...
    (microsoft.public.vb.general.discussion)
  • Re: Cusotm User Control Bitmap Drawing Issues...
    ... I reversed the row/column values when drawing ... So I was trying to draw off the bitmap. ... > try to set a pixel to black. ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: How to clip histogram?
    ... i tried this for simple clipping, but it is not clipping any thing.. ... grayImage = rgb2gray; ... pixel = pixel; ...
    (comp.soft-sys.matlab)