当前位置: 首页>>代码示例>>C#>>正文


C# Paint.SetColorFilter方法代码示例

本文整理汇总了C#中Android.Graphics.Paint.SetColorFilter方法的典型用法代码示例。如果您正苦于以下问题:C# Paint.SetColorFilter方法的具体用法?C# Paint.SetColorFilter怎么用?C# Paint.SetColorFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Paint的用法示例。


在下文中一共展示了Paint.SetColorFilter方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);

            SetContentView(Resource.Layout.Main);

            _colorMatrix = new ColorMatrix();
            _colorMatrixFilter = new ColorMatrixColorFilter(_colorMatrix);

            _paint = new Paint();
            _paint.SetColorFilter(_colorMatrixFilter);

            var contrast = FindViewById<SeekBar>(Resource.Id.contrast);
            contrast.KeyProgressIncrement = 1;
            contrast.ProgressChanged += ContrastChanged;

            var brightness = FindViewById<SeekBar>(Resource.Id.brightness);
            brightness.KeyProgressIncrement = 1;
            brightness.ProgressChanged += BrightnessChanged;

            var saturation = FindViewById<SeekBar>(Resource.Id.saturation);
            saturation.KeyProgressIncrement = 1;
            saturation.ProgressChanged += SaturationChanged;

            var imageSelector = FindViewById<Button>(Resource.Id.selectImage);
            imageSelector.Click += ImagesSelectorClick;

            _imageViewer = FindViewById<ImageView>(Resource.Id.imageViewer);
        }
开发者ID:aca1490,项目名称:Basic-Image-Editor,代码行数:30,代码来源:MainActivity.cs

示例2: Transform

        public Bitmap Transform(Bitmap source)
        {
            Bitmap result = Bitmap.CreateBitmap(source.Width, source.Height, source.GetConfig());
            Bitmap noise;
            try
            {
                noise = picasso.Load(Resource.Drawable.noise).Get();
            }
            catch (Exception)
            {
                throw new Exception("Failed to apply transformation! Missing resource.");
            }

            BitmapShader shader = new BitmapShader(noise, Shader.TileMode.Repeat, Shader.TileMode.Repeat);

            ColorMatrix colorMatrix = new ColorMatrix();
            colorMatrix.SetSaturation(0);
            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);

            Paint paint = new Paint(PaintFlags.AntiAlias);
            paint.SetColorFilter(filter);

            Canvas canvas = new Canvas(result);
            canvas.DrawBitmap(source, 0, 0, paint);

            paint.SetColorFilter(null);
            paint.SetShader(shader);
            paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.Multiply));

            canvas.DrawRect(0, 0, canvas.Width, canvas.Height, paint);

            source.Recycle();
            noise.Recycle();

            return result;
        }
开发者ID:fitzhex,项目名称:testrepo,代码行数:36,代码来源:GrayscaleTransformation.cs

示例3: ToGreyScale

        public static Bitmap ToGreyScale(this Bitmap bmp)
        {
            if (bmp == null) return null;

            var height = bmp.Height;
            var width = bmp.Width;
            var bmpGrayscale = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            var canvas = new Canvas(bmpGrayscale);
            var paint = new Paint();
            var cm = new ColorMatrix();
            cm.SetSaturation(0);
            var filter = new ColorMatrixColorFilter(cm);
            paint.SetColorFilter(filter);
            canvas.DrawBitmap(bmp, 0, 0, paint);
            return bmpGrayscale;
        } 
开发者ID:geekpivot,项目名称:HealthClinic.biz,代码行数:16,代码来源:BitmapExtensions.cs

示例4: ToColorSpace

		public static Bitmap ToColorSpace(Bitmap source, ColorMatrix colorMatrix)
		{
			int width = source.Width;
			int height = source.Height;

			Bitmap bitmap = Bitmap.CreateBitmap(width, height, source.GetConfig());

			using (Canvas canvas = new Canvas(bitmap))
			using (Paint paint = new Paint())
			{
				paint.SetColorFilter(new ColorMatrixColorFilter(colorMatrix));
				canvas.DrawBitmap(source, 0, 0, paint);

				return bitmap;	
			}
		}
开发者ID:zenjoy,项目名称:FFImageLoading,代码行数:16,代码来源:ColorSpaceTransformation.cs

示例5: Transform

        protected override Bitmap Transform(Bitmap source)
        {
            int width = source.Width;
            int height = source.Height;

            Bitmap bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint();
            paint.AntiAlias = true;
            paint.SetColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SrcAtop));
            canvas.DrawBitmap(source, 0, 0, paint);
            source.Recycle();

            return bitmap;
        }
开发者ID:dbeattie71,项目名称:FFImageLoading,代码行数:16,代码来源:ColorFilterTransformation.cs

示例6: Transform

        protected override Bitmap Transform(Bitmap source)
        {
            int width = source.Width;
            int height = source.Height;

            Bitmap bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

            Canvas canvas = new Canvas(bitmap);
            ColorMatrix saturation = new ColorMatrix();
            saturation.SetSaturation(0f);
            Paint paint = new Paint();
            paint.SetColorFilter(new ColorMatrixColorFilter(saturation));
            canvas.DrawBitmap(source, 0, 0, paint);
            source.Recycle();

            return bitmap;
        }
开发者ID:dbeattie71,项目名称:FFImageLoading,代码行数:17,代码来源:GrayscaleTransformation.cs

示例7: OnDraw

        protected override void OnDraw(Canvas canvas)
        {
            if (_image != null && _filter != null) {
                var cFilter = new ColorMatrixColorFilter (_filter);
                Paint paint = new Paint ();
                paint.SetColorFilter (cFilter);

                Matrix matrix = new Matrix ();
                canvas.Save ();
                float horizotalScale = (Right - Left) / (float)_image.Width;
                float verticalScale = (Bottom - Top) / (float)_image.Height;
                float scale = horizotalScale < verticalScale ? horizotalScale : verticalScale;

                matrix.SetScale (scale,scale);

                canvas.DrawBitmap (_image, matrix, paint);
                canvas.Restore ();
            }
        }
开发者ID:RomanYemelyanenko,项目名称:CropImageTool,代码行数:19,代码来源:FilterImageView.cs

示例8: ToSolidColor

		public static Bitmap ToSolidColor(Bitmap sourceBitmap, int r, int g, int b, int a)
		{
			var config = sourceBitmap?.GetConfig();
			if (config == null)
			{
				config = Bitmap.Config.Argb8888;
			}

			int width = sourceBitmap.Width;
			int height = sourceBitmap.Height;

			Bitmap bitmap = Bitmap.CreateBitmap(width, height, config);

			using (Canvas canvas = new Canvas(bitmap))
			{
				using (Paint paint = new Paint())
				{
					PorterDuffColorFilter cf = new PorterDuffColorFilter(Color.Argb(a, r, g, b), PorterDuff.Mode.SrcAtop);
					paint.SetColorFilter(cf);
					canvas.DrawBitmap(sourceBitmap, 0, 0, paint);
					return bitmap;
				}
			}
		}
开发者ID:daniel-luberda,项目名称:FFImageLoading,代码行数:24,代码来源:TintTransformation.cs

示例9: ToColorSpace

		public static Bitmap ToColorSpace(Bitmap source, ColorMatrix colorMatrix)
		{
			var config = source.GetConfig();
            		if (config == null)
                		config = Bitmap.Config.Argb8888;    // This will support transparency
			
			int width = source.Width;
			int height = source.Height;

			Bitmap bitmap = Bitmap.CreateBitmap(width, height, config);

			using (Canvas canvas = new Canvas(bitmap))
			using (Paint paint = new Paint())
			{
				paint.SetColorFilter(new ColorMatrixColorFilter(colorMatrix));
				canvas.DrawBitmap(source, 0, 0, paint);

				return bitmap;	
			}
		}
开发者ID:CaLxCyMru,项目名称:FFImageLoading,代码行数:20,代码来源:ColorSpaceTransformation.cs

示例10: GetRoundedCornerBitmap

		public static Bitmap GetRoundedCornerBitmap (Bitmap bitmap, int cornerRadius)
		{
			Bitmap output = Bitmap.CreateBitmap (bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);

			Canvas canvas = new Canvas(output);

			Paint paint = new Paint();
			Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
			RectF rectF = new RectF(rect);
			float roundPx = cornerRadius;

			paint.AntiAlias = true;
			canvas.DrawARGB(0, 0, 0, 0);
			paint.SetColorFilter (new ColorFilter ());
			canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);
			paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn));
			canvas.DrawBitmap (bitmap, rect, rect, paint);

			return output;
		}
开发者ID:Gerhic,项目名称:Need2Park,代码行数:20,代码来源:UIImageView.cs

示例11: GetBrushImageWithColor

        private ImageView GetBrushImageWithColor(ImageView brushImage, Android.Graphics.Color color)
        {
            ImageView toReturn = new ImageView (context);
            using (Bitmap sourceBitmap = brushImage.DrawingCache) {
                if (sourceBitmap != null) {
                    float R = (float)color.R;
                    float G = (float)color.G;
                    float B = (float)color.B;

                    float[] colorTransform =
                {
                    R / 255f  ,0         ,0       ,0,  0,                 // R color
                    0,          G / 255f   ,   0      ,0  ,0                      // G color
                    ,0    ,0 ,          B / 255f, 0, 0                        // B color
                    ,0    ,0             ,0          ,1f  ,0f
                };

                    ColorMatrix colorMatrix = new ColorMatrix ();
                    colorMatrix.SetSaturation (0f); //Remove Colour

                    colorMatrix.Set (colorTransform);
                    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter (colorMatrix);
                    Paint paint = new Paint ();
                    paint.SetColorFilter (colorFilter);

                    Bitmap mutableBitmap = sourceBitmap.Copy (Bitmap.Config.Argb8888, true);
                    toReturn.SetImageBitmap (mutableBitmap);
                    Canvas canvas = new Canvas (mutableBitmap);
                    canvas.DrawBitmap (mutableBitmap, 0, 0, paint);
                }
            }
            return toReturn;
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:33,代码来源:BrushItem.cs

示例12: changeBitmapContrastBrightness

        public static Bitmap changeBitmapContrastBrightness (Bitmap bmp, float contrast, float brightness)
        {
            ColorMatrix cm = new ColorMatrix (new float[] {
                contrast, 0, 0, 0, brightness,
                0, contrast, 0, 0, brightness,
                0, 0, contrast, 0, brightness,
                0, 0, 0, 1, 0
            });
            cm.SetSaturation (0);

            Bitmap ret = Bitmap.CreateBitmap (bmp.Width, bmp.Height, bmp.GetConfig ());

            Canvas canvas = new Canvas (ret);

            Paint paint = new Paint ();
            paint.SetColorFilter (new ColorMatrixColorFilter (cm));
            canvas.DrawBitmap (bmp, 0, 0, paint);

            return ret;
        }
开发者ID:Tolulope,项目名称:Tesseract.Xamarin,代码行数:20,代码来源:TesseractApi.cs


注:本文中的Android.Graphics.Paint.SetColorFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。