主题。
有一个背景。
还有一张图片需要放在背景上
。透明边缘的问题。
它应该是这样的(放大图像以使其清晰),这是来自 Photoshop 的图片。
我这样理解




我用来粘合图像的代码。
public static Bitmap Glue(Bitmap sourse, Bitmap img)
{
Bitmap result = sourse;
for (int w = 0; w< result.Width; w++)
{
for (int h = 0; h < result.Height; h++)
{
Color pixelColor = img.GetPixel(w, h);
if(pixelColor.R != 0 && pixelColor.G != 0 && pixelColor.B != 0 || pixelColor.A != 0 )
{
result.SetPixel(w, h, pixelColor);
}
}
}
return result;
}
}
实际上如何获得边缘平滑的图片?这可以通过简单地正确替换像素来完成,还是边缘由 Photoshop 和其他编辑器中的某种算法处理?
您已经走得太远了,GDI+ (
System.Drawing) 已经知道您需要的一切。哪里
back.png- 背景,image.png- 图标,result.png- 完成的图像。通常,如果您需要处理一组像素,则永远不要使用
GetPixel/ - 这是一种处理图像的超慢方法。以下是快速处理图片的其他方法。SetPixel