程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#實現淡入淡出顯示圖像效果顯示圖片(2)

C#實現淡入淡出顯示圖像效果顯示圖片(2)

編輯:關於C語言
出效果代碼如下:
private void button3_Click(object sender, EventArgs e)
{
//淡出顯示圖像
try
{
Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Gray);
int width = MyBitmap.Width;
int height = MyBitmap.Height;
ImageAttributes attributes = new ImageAttributes();
ColorMatrix matrix = new ColorMatrix();
//創建淡出顏色矩陣
matrix.Matrix00 = (float)0.0;
matrix.Matrix01 = (float)0.0;
matrix.Matrix02 = (float)0.0;
matrix.Matrix03 = (float)0.0;
matrix.Matrix04 = (float)0.0;
matrix.Matrix10 = (float)0.0;
matrix.Matrix11 = (float)0.0;
matrix.Matrix12 = (float)0.0;
matrix.Matrix13 = (float)0.0;
matrix.Matrix14 = (float)0.0;
matrix.Matrix20 = (float)0.0;
matrix.Matrix21 = (float)0.0;
matrix.Matrix22 = (float)0.0;
matrix.Matrix23 = (float)0.0;
matrix.Matrix24 = (float)0.0;
matrix.Matrix30 = (float)0.0;
matrix.Matrix31 = (float)0.0;
matrix.Matrix32 = (float)0.0;
matrix.Matrix33 = (float)0.0;
matrix.Matrix34 = (float)0.0;
matrix.Matrix40 = (float)0.0;
matrix.Matrix41 = (float)0.0;
matrix.Matrix42 = (float)0.0;
matrix.Matrix43 = (float)0.0;
matrix.Matrix44 = (float)0.0;
matrix.Matrix33 = (float)1.0;
matrix.Matrix44 = (float)1.0;
//從1到0進行修改色彩變換矩陣主對角線上的數值
//依次減少每種色彩分量
Single count = (float)1.0;
while (count > 0.0)
{
matrix.Matrix00 = (float)count;
matrix.Matrix11 = (float)count;
matrix.Matrix22 = (float)count;
matrix.Matrix33 = (float)count;
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(MyBitmap, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel, attributes);
System.Threading.Thread.Sleep(20);
count = (float)(count - 0.01);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "信息提示");
}
}
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved