Tag: drawing2d

.NET – 围绕resize的图像边框

我正在尝试在.NET中调整图像大小,但在resize的图像周围会出现一个模糊的黑色边框。 我发现了一篇posthttp://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/cf765094-c8c1-4991-a1f3-cecdbd07ee15/ ,其中有人说目标矩形大于canvas工作,但这对我不起作用。 它有顶部和左边的边缘,但右边和底部仍然存在,并且是一个完整的1px厚的黑色。 我错过了什么吗? 我的代码如下。 Image image = … // this is a valid image loaded from the source Rectangle srcRectangle = new Rectangle(0,0,width, height); Size croppedFullSize = new Size(width+3,height+3); Rectangle destRect = new Rectangle(new Point(-1,-1), croppedFullSize); using(Bitmap newImage = new Bitmap(croppedFullSize.Width, croppedFullSize.Height, format)) using(Graphics Canvas = Graphics.FromImage(newImage)) { Canvas.SmoothingMode = SmoothingMode.AntiAlias; Canvas.InterpolationMode = […]

如何使用GDI +绘制环形(甜甜圈)?

我一直试图在C#中绘制一个带有透明孔和渐变边缘的环 (厚度环),但收效甚微。 有没有人对如何做到这一点有任何建议? 这是一个很好的Blend Utility 这是最终结果 – 感谢BlueMonkMN Rectangle GetSquareRec(double radius, int x, int y) { double r = radius; double side = Math.Sqrt(Math.Pow(r, 2) / 2); Rectangle rec = new Rectangle(x – ((int)side), y – ((int)side), (int)(side * 2) + x, (int)(side * 2) + y); return rec; } void Form1_Paint(object sender, PaintEventArgs e) […]

如何知道线是否与矩形相交

我已经查看了这个问题,但答案对我来说非常大: 如何知道一条线是否与C#中的平面相交? – 基本2D几何 是否有任何.NET方法可以知道由两个点定义的直线是否与矩形相交? public bool Intersects(Point a, Point b, Rectangle r) { // return true if the line intersects the rectangle // false otherwise } 提前致谢。