半透明图像生成程序

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();
原文地址:https://www.cnblogs.com/lidune/p/546676.html