110,567
社区成员
发帖
与我相关
我的任务
分享
<div style="position:absolute;top:127px;left:40px; width:315px;height:132px; z-index:100;" id="div1">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td></td>
</tr>
</table>
</div>
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.Drawing.Imaging;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int i = 0;
public Form1()
{
InitializeComponent();
Application.Idle +=new EventHandler(Application_Idle);
}
void Application_Idle(object sender, EventArgs e)
{
panel1.Refresh();
Point StartPoint = panel1.PointToScreen(new Point(0, 0));
Bitmap capturedBMP =new Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(capturedBMP, new Rectangle(0, 0, panel1.Width, panel1.Height));
Bitmap mixImage = new Bitmap(capturedBMP.Width, capturedBMP.Height);
Graphics g = Graphics.FromImage(mixImage);
float[][] colormatrix ={
new float[]{1,0,0,0,0},//代表了R
new float[]{0,1,0,0,0},//代表了G
new float[]{0,0,1,0,0},//代表了B
new float[]{0,0,0,0.6f,0},//代表了A
new float[]{0,0,0,0,1}
};
ColorMatrix cm = new ColorMatrix(colormatrix);
ImageAttributes imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(capturedBMP, new Rectangle(0, 0, capturedBMP.Width, capturedBMP.Height), 0, 0, capturedBMP.Width, capturedBMP.Height, GraphicsUnit.Pixel, imageAtt);
pictureBox1.Image = mixImage;
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = i.ToString();
i++;
}
}
}