Bitmap bit = new Bitmap(80,80);
Graphics graph = Graphics.FromImage(bit);
Bitmap bit1 = new Bitmap(Server.MapPath("Image/tu4.png"));
Bitmap bit2 = new Bitmap(Server.MapPath("Image/ren.png"));
Bitmap bit3 = new Bitmap(Server.MapPath("Image/tu3.png"));
Bitmap bit4 = new Bitmap(Server.MapPath("Image/add.png"));
graph.Clear(Color.White);
graph.DrawImage(bit,0,0);
graph.DrawImage(bit1, 0, 0, 40, 40);
graph.DrawImage(bit2, 40, 40, 40, 40);
graph.DrawImage(bit3, 0, 40, 40, 40);
graph.DrawImage(bit4, 40, 0, 40, 40);
bit.Save(Server.MapPath("Image/a.jpg"));
我四张图合成放在一个大图上, 不过我像要每个小图是个园的,效果, 求大神!!
------解决思路----------------------
图片没有圆的,它必须是方的
不过可以看起来是圆的
你画完计算一下,把圆外面的点变成别的颜色,或者设置成透明色,不就得了
------解决思路----------------------
参考网上代码
private void Form1_Paint(object sender, PaintEventArgs e)
{
string filename = "icon.png";//如果不是png类型,须转换
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(filename);
for (int y = 0; y < 100; y++)
{
for (int x = 0; x < 100; x++)
{
if ((x - 50) * (x - 50) + (y - 50) * (y - 50) > 50 * 50)
{
bitmap.SetPixel(x, y, System.Drawing.Color.FromArgb(0, 255, 255, 255));
}
}
}
Graphics g = CreateGraphics();
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawImage(bitmap, new Point(50, 50));
g.DrawEllipse(new Pen(Color.LightGray), 50, 50, 100, 100);
g.Dispose();
}