四
以分塊效果顯示圖像
原理: 首先將圖分為幾塊
再使用 Bitmap 類的 Clone方法從原圖指定的塊中復制圖像
最後將這些塊依次顯示出來便可
代碼:
private void button
_Click(object sender
EventArgs e)
{
Graphics g = this
panel
CreateGraphics();
g
Clear(Color
White);
int width = MyBitmap
Width;
int height = MyBitmap
Height;
//定義將圖片切分成四個部分的區域
RectangleF[] block ={
new RectangleF(
width/
height/
)
new RectangleF(width/
width/
height/
)
new RectangleF(
height/
width/
height/
)
new RectangleF(width/
height/
width/
height/
)};
//分別克隆圖片的四個部分
Bitmap[] MyBitmapBlack ={
MyBitmap
Clone(block[
]
System
Drawing
Imaging
PixelFormat
DontCare)
MyBitmap
Clone(block[
]
System
Drawing
Imaging
PixelFormat
DontCare)
MyBitmap
Clone(block[
]
System
Drawing
Imaging
PixelFormat
DontCare)
MyBitmap
Clone(block[
]
System
Drawing
Imaging
PixelFormat
DontCare)};
//繪制圖片的四個部分
各部分繪制時間間隔為
秒
g
DrawImage(MyBitmapBlack[
]
);
System
Threading
Thread
Sleep(
);
g
DrawImage(MyBitmapBlack[
]
width /
);
System
Threading
Thread
Sleep(
);
g
DrawImage(MyBitmapBlack[
]
width /
height /
);
System
Threading
Thread
Sleep(
);
g
DrawImage(MyBitmapBlack[
]
height /
);
}
五 以淡入淡出效果顯示圖像
原理: 使用 ImageAttrributes 類的 SetColorMatrix() 方法設置顏色 調整矩陣實現淡出的效果 此類還可以對顏色進行校正 調暗 調亮和移除等
代碼:
private void button
_Click(object sender
EventArgs e)
{
try
{
Graphics g = this
panel
CreateGraphics();
g
Clear(Color
Gray);
int width = MyBitmap
Width;
int height = MyBitmap
Height;
ImageAttributes attributes = new ImageAttributes();
ColorMatrix matrix = new ColorMatrix();
//創建淡入顏色矩陣
[] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/net/201311/14936.html