防止过度铺设的影响?

时间:2013-11-13 17:26:11

标签: c# image effect

所以基本上我有2个效果。 1是棕褐色,另一个是Aqua效果,当我将Aqua效果放在图像上然后将棕褐色效果放在上面时,棕褐色效果会覆盖Aqua。我不明白它为什么要这样做,我知道要为它添加一个额外的图片框并使图片框不可见但是这不是一种有效的方法,它们必须是另一种更有效的方法,它可以有人请分享?

棕褐色

private void btnGrayscale_Click(object sender, EventArgs e)
{

Bitmap grayScale = (Bitmap)picOriginal.Image.Clone();
int height = grayScale.Size.Height;
int width = grayScale.Size.Width;    
for (int yCoordinate = 0; yCoordinate < height; yCoordinate++)

{

for (int xCoordinate = 0; xCoordinate < width; xCoordinate++)

{
Color color = grayScale.GetPixel(xCoordinate, yCoordinate);
int grayColor = (color.R + color.G + color.B) / 3;
grayScale.SetPixel(xCoordinate, yCoordinate,     Color.FromArgb(grayColor,grayColor,grayColor));

 }

} 
 picModified.Image = grayScale;

}

 ColorMatrix matrix = new ColorMatrix(new float[][]{
 new float[] {0, 4, 0, 0, 0},
 new float[] {0, 0, 4, 0, 4},
 new float[] {0, 0, 0, 4, 0},
 new float[] {     0,      0,      4, 0, 1},
  new float[] {     0,      0,      0, 4, 0}
 });

 Image image = (Bitmap)picOriginal.Image.Clone();
 ImageAttributes attributes = new ImageAttributes();
 attributes.SetColorMatrix(matrix);
 Graphics graphics = Graphics.FromImage(image);
 graphics.DrawImage(image,

 new Rectangle(0, 0, image.Width, image.Height),0,0,image.Width,image.Height,
 GraphicsUnit.Pixel,attributes);

 graphics.Dispose();


 picModified.Image = image;


 }

0 个答案:

没有答案