C# 图片覆盖问题
发布网友
发布时间:2024-05-15 12:21
我来回答
共3个回答
热心网友
时间:2024-07-16 21:32
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Drawing.Drawing2D;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
td = new Thread(new ThreadStart(startPrint));
td.IsBackground = true;
}
Thread td;
private void startPrint()
{
do
{
Graphics g = pic1.CreateGraphics();
Rectangle[] rec1 = {new Rectangle (0,0,pic1.Width,pic1 .Height),
new Rectangle (pic1 .Width /2-50,pic1 .Height /2-50,100,100)
};
g.FillRectangle(new SolidBrush(Color.BlueViolet ), rec1[0]);
g.FillEllipse (new SolidBrush(Color.Red), rec1[1]);
Thread.Sleep(1000);
g.FillRectangle(new SolidBrush(Color.BlueViolet), rec1[0]);
g.FillEllipse(new SolidBrush(Color.Green ), rec1[1]);
Thread.Sleep(1000);
} while (1 == 1);
}
private void Form1_Load(object sender, EventArgs e)
{
td.Start();
}
}
}
测试通过DA☆ZE
热心网友
时间:2024-07-16 21:31
Graphics g = this.CreateGraphics();
g.DrawPie(...)
其它逻辑自已处理,时间控制,多线程处理?Image.FromStream/File/.....
DrawXXXX
热心网友
时间:2024-07-16 21:29
<script type="text/javascript">
var num=0;
var SetTime;
function ChangeImg()
{
num++;
if(num==4)
{
num=0; //图片到Pic4 返回到第一张图片
}
var imgSrc="images/pic"+num+".jpg";
document.getElementById("img").src =imgSrc;
SetTime=setTimeout("ChangeImg()",10000); //间隔十秒执行一次程序
}
function StopChange()
{
clearTimeout(SetTime);
}
</script>
<style type="text/css">
.div1{
margin:0 auto;
width:80%;
border:1ps solid #000000;
background-color:#0099FF;
height:500px;
}
</style>
</head>
<body>
<div class="div1">
<img id="img" src="images/pic1.jpg" />
<input type="button" onclick="ChangeImg()" value="开始切换"/>
<input type="button" onclick="StopChange()" value="开始切换"/>
</div>