.Net技术联盟

专注于.NET技术

导航

半透明图像生成程序

Posted on 2006-11-01 13:34  一样的云  阅读(218)  评论(0编辑  收藏  举报
Graphics g=pictureBox2.CreateGraphics();
            Bitmap bitmap
=new Bitmap(openFileDialog1.FileName);
            
float[][] matrixitems=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,0.2f,0},
            
new float[]{0,0,0,0,1}
            }
;
            ColorMatrix colormatrix
=new ColorMatrix(matrixitems);
            ImageAttributes imageAtt
=new ImageAttributes();
            imageAtt.SetColorMatrix(colormatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
            
int iWidth=bitmap.Width;
            
int iHeight=bitmap.Height;
            
//g.DrawLine(new Pen(Color.Black,25),new Point(10,35),new Point(200,35));
            g.DrawImage(bitmap,new Rectangle(30,0,iWidth,iHeight),0,0,iWidth,iHeight,GraphicsUnit.Pixel,imageAtt);    
            bitmap.Dispose();
            g.Dispose();