本文介绍了如何制作擦除笔/笔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用简单的擦除笔/笔擦除透明位图的某些部分(具有擦除不透明度)的最佳方法是什么?

whats the best way to make a simple erase brush / pen to erase parts of a transparency bitmap (with erase opacity)?

推荐答案


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, opacity, 0}, //opacity is between 0 and 1
                               new float[] {0, 0, 0, 0, 1}};
            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(matrixItems);

            // Create an ImageAttributes object and set its color matrix.
            System.Drawing.Imaging.ImageAttributes imageAtt = new System.Drawing.Imaging.ImageAttributes();
            imageAtt.SetColorMatrix(colorMatrix,
                System.Drawing.Imaging.ColorMatrixFlag.Default,
                System.Drawing.Imaging.ColorAdjustType.Bitmap);
            RectangleF newRectangleF = new RectangleF(0.0f, 0.0f, YourImage.Width, YourImage.Height);
            // Create a TextureBrush using the bitmap and the specified ImageAttributes 
            TextureBrush newTextureBrush = new TextureBrush(YourImage, newRectangleF, imageAtt);



基于msdn代码的不透明纹理画笔



based on the msdn code for a texturebrush with opacity


这篇关于如何制作擦除笔/笔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 23:54