星期日, 2月 24, 2008

c# 畫透明圖

private void drawTransparentImage()
{
Graphics g = pictureBox1.CreateGraphics();

Bitmap bitmap = new Bitmap(Resources.PDA1, pictureBox1.Size);
float[][] ptsArray ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, f, 0},
new float[] {0, 0, 0, 0, 1}};

ColorMatrix clrMatrix = new ColorMatrix(ptsArray);
ImageAttributes imgAttributes = new ImageAttributes();
imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

g.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height),
0, 0, bitmap.Width, bitmap.Height,
GraphicsUnit.Pixel, imgAttributes);

g.Dispose();
}

沒有留言: