大家好,又见面了,我是你们的朋友全栈君。
private void pictureBox1_Click(object sender, EventArgs e)
{
Image Imageimage;
Imageimage = System.Drawing.Image.FromFile(@"D:\black.png");
Bitmap bitmap = new Bitmap(Imageimage);
bitmap.MakeTransparent(Color.White);
Imageimage = System.Drawing.Image.FromFile(@"D:\white.png");
Bitmap bitmap1 = new Bitmap(Imageimage);
bitmap1.MakeTransparent(Color.Black);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(pictureBox1.BackColor);
for (int j = 0; j < 4; j++)
for (int i = 0; i < 5; i++)
{
Image x;
Random random = new Random();
int n = random.Next(1, 3);
if (n==1)
{
x = bitmap;
g.DrawImage(x, new Point(i * 100, j * 100));
}
if(n==2)
{
x = bitmap1;
g.DrawImage(x, new Point(i * 100, j * 100));
}
}
//pictureBox1.Image = bitmap;
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/162719.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...