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


C# Paint.SetXfermode方法代码示例

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


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

示例1: GetRoundedCornerBitmap

		// If you would like to create a circle of the image set pixels to half the width of the image.
		internal static   Bitmap GetRoundedCornerBitmap(Bitmap bitmap, int pixels)
		{
			Bitmap output = null;

			try
			{
				output = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);
				Canvas canvas = new Canvas(output);

				Color color = new Color(66, 66, 66);
				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
				RectF rectF = new RectF(rect);
				float roundPx = pixels;

				paint.AntiAlias = true;
				canvas.DrawARGB(0, 0, 0, 0);
				paint.Color = color;
				canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);

				paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
				canvas.DrawBitmap(bitmap, rect, rect, paint);
			}
			catch (System.Exception err)
			{
				System.Console.WriteLine ("GetRoundedCornerBitmap Error - " + err.Message);
			}

			return output;
		}
开发者ID:suchithm,项目名称:SampleImageBitMap,代码行数:31,代码来源:ImageHelper.cs

示例2: GetCroppedBitmap

        static Bitmap GetCroppedBitmap (Bitmap bmp, int radius)
        {
            Bitmap sbmp;
            if (bmp.Width != radius || bmp.Height != radius)
                sbmp = Bitmap.CreateScaledBitmap (bmp, radius, radius, false);
            else
                sbmp = bmp;
            var output = Bitmap.CreateBitmap (sbmp.Width,
                             sbmp.Height, Bitmap.Config.Argb8888);
            var canvas = new Canvas (output);

            var paint = new Paint ();
            var rect = new Rect (0, 0, sbmp.Width, sbmp.Height);

            paint.AntiAlias = true;
            paint.FilterBitmap = true;
            paint.Dither = true;
            canvas.DrawARGB (0, 0, 0, 0);
            paint.Color = Color.ParseColor ("#BAB399");
            canvas.DrawCircle (sbmp.Width / 2 + 0.7f, sbmp.Height / 2 + 0.7f,
                sbmp.Width / 2 + 0.1f, paint);
            paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn));
            canvas.DrawBitmap (sbmp, rect, rect, paint);

            return output;
        }
开发者ID:vgvassilev,项目名称:couchbase-connect-14,代码行数:26,代码来源:RoundedImageView.cs

示例3: BezelImageView

	    public BezelImageView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
		{
			// Attribute initialization
	        var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.BezelImageView, defStyle, 0);
	
	        mMaskDrawable = a.GetDrawable(Resource.Styleable.BezelImageView_maskDrawable);
	        if (mMaskDrawable == null) {
	            mMaskDrawable = Resources.GetDrawable(Resource.Drawable.bezel_mask);
	        }
	        mMaskDrawable.Callback = this;
	
	        mBorderDrawable = a.GetDrawable(Resource.Styleable.BezelImageView_borderDrawable);
	        if (mBorderDrawable == null) {
	            mBorderDrawable = Resources.GetDrawable(Resource.Drawable.bezel_border);
	        }
	        mBorderDrawable.Callback = this;
	
	        a.Recycle();
	
	        // Other initialization
	        mMaskedPaint = new Paint();
	        mMaskedPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcAtop));
	
	        mCopyPaint = new Paint();
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:25,代码来源:BezelImageView.cs

示例4: CreateEraser

        public static Paint CreateEraser()
        {
            var eraserPaint = new Paint();
            eraserPaint.Color = Color.Transparent;
            eraserPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.Clear));
            eraserPaint.Flags = PaintFlags.AntiAlias;

            return eraserPaint;
        }
开发者ID:mattleibow,项目名称:AppShowcase,代码行数:9,代码来源:AnimationHelpers.cs

示例5: GetRoundedCornerBitmap

 public static Bitmap GetRoundedCornerBitmap(this Bitmap bitmap, int roundPixelSize)
 {
     Bitmap output = Bitmap.CreateBitmap(bitmap.Width, bitmap.Height, Bitmap.Config.Argb8888);
     var canvas = new Canvas(output);
     var paint = new Paint();
     var rect = new Rect(0, 0, bitmap.Width, bitmap.Height);
     var rectF = new RectF(rect);
     var roundPx = roundPixelSize;
     paint.AntiAlias = true;
     canvas.DrawRoundRect(rectF,roundPx,roundPx, paint);
     paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
     canvas.DrawBitmap(bitmap, rect, rect, paint);
     return output;
 }
开发者ID:okrotowa,项目名称:Yorsh,代码行数:14,代码来源:BitmapExtensions.cs

示例6: ClingDrawer

        public ClingDrawer(Resources resources, Color showcaseColor)
        {
            this.showcaseColor = showcaseColor;

            PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.Clear);
            mEraser = new Paint();
            mEraser.Color = Color.White;
            mEraser.Alpha = 0;
            mEraser.SetXfermode(mBlender);
            mEraser.AntiAlias = true;

            mShowcaseDrawable = resources.GetDrawable(Resource.Drawable.cling_bleached);
            mShowcaseDrawable.SetColorFilter(showcaseColor, PorterDuff.Mode.Multiply);
        }
开发者ID:andyci,项目名称:ShowcaseView,代码行数:14,代码来源:ClingDrawer.cs

示例7: GetRoundedCornerBitmap

 public static Bitmap GetRoundedCornerBitmap(this Bitmap bitmap, int? roundPixelSize = null)
 {
     var chooseSize = bitmap.Width > bitmap.Height ? bitmap.Height : bitmap.Width;
     roundPixelSize = roundPixelSize ?? (int)Application.Context.Resources.GetDimension(Resource.Dimension.RoundedCorners);
     var output = Bitmap.CreateBitmap(chooseSize, chooseSize, Bitmap.Config.Argb8888);
     var canvas = new Canvas(output);
     var paint = new Paint();
     var rect = new Rect(0, 0, chooseSize, chooseSize);
     var rectF = new RectF(rect);
     var roundPx = roundPixelSize.Value;
     paint.AntiAlias = true;
     canvas.DrawRoundRect(rectF, roundPx, roundPx, paint);
     paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
     canvas.DrawBitmap(bitmap, rect, rect, paint);
     return output;
 }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:16,代码来源:BitmapExtensions.cs

示例8: Evaluate

		public Java.Lang.Object Evaluate (float fraction, Java.Lang.Object startValue, Java.Lang.Object endValue)
		{
			var bmp1 = startValue as Bitmap;
			var bmp2 = endValue as Bitmap;
			if (cacheBitmap == null)
				cacheBitmap = Bitmap.CreateBitmap (bmp1.Width, bmp1.Height, Bitmap.Config.Argb8888);
			if (blendPaint == null) {
				blendPaint = new Paint ();
				blendPaint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcOver));
			}

			using (var canvas = new Canvas (cacheBitmap)) {
				canvas.DrawBitmap (bmp1, 0, 0, null);
				blendPaint.Alpha = (int)((1 - fraction) * 255);
				canvas.DrawBitmap (bmp2, 0, 0, blendPaint);
			}
			return cacheBitmap;
		}
开发者ID:JovinPJ,项目名称:Moyeu,代码行数:18,代码来源:BitmapEvaluator.cs

示例9: CategoryBadge

        static CategoryBadge()
        {
            center = OverallSize / 2;
            mainCenter = center + offset;

            backPaint = new Paint () {
                Color = Color.Rgb (0xc7, 0xc7, 0xc7),
                AntiAlias = true
            };
            backPaint.SetShader (new LinearGradient (mainCenter, 0, mainCenter, radius * 2,
                                                     Color.Rgb (0xc7, 0xc7, 0xc7),
                                                     Color.Argb (0xa2, 0xc7, 0xc70, 0xc7),
                                                     //Color.Argb (0xa2, 0xc7, 0xc7, 0xc7),
                                                     Shader.TileMode.Clamp));
            darkerBackPaint = new Paint () {
                Color = Color.Rgb (0xa7, 0xa7, 0xa7),
                AntiAlias = true
            };
            shadowPaint = new Paint () {
                Color = Color.Rgb (0x9a, 0x9a, 0x9a),
                AntiAlias = true
            };
            removePaint = new Paint () {
                AntiAlias = true,
                Color = Color.White,
                TextAlign = Paint.Align.Center,
                TextSize = 14.ToPixels ()
            };
            //removePaint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.Clear));
            removePaint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.DstIn));
            redPaint = new Paint () {
                Color = Color.Rgb (0xff, 0x44, 0x44),
                AntiAlias = true
            };
            greenPaint = new Paint () {
                Color = Color.Rgb (0x99, 0xcc, 0x00),
                AntiAlias = true
            };
            imgPaint = new Paint () {
                AntiAlias = false,
                FilterBitmap = false
            };
        }
开发者ID:Andrea,项目名称:FriendTab,代码行数:43,代码来源:CategoryBadge.cs

示例10: 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

示例11: GetOvalBitmap

		/// <summary>
		/// Gets the oval bitmap.
		/// </summary>
		/// <returns>The oval bitmap.</returns>
		/// <param name="bitmap">Bitmap.</param>
		private Bitmap GetOvalBitmap(Bitmap bitmap) 
		{
			Bitmap output = null;

			if(bitmap != null)
			{
				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);

				paint.AntiAlias = true;
				canvas.DrawARGB(0, 0, 0, 0);
				paint.Color = Color.Red;
				canvas.DrawOval(rectF, paint);

				paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
				canvas.DrawBitmap(bitmap, rect, rect, paint);
			}

			return output;
		}
开发者ID:newky2k,项目名称:GravatarMobile,代码行数:29,代码来源:GravatarView.cs

示例12: OnDraw

        protected override void OnDraw(Shape shape, Android.Graphics.Canvas canvas, Paint paint)
        {
            var height = canvas.ClipBounds.Bottom;
            var width = canvas.ClipBounds.Right;
            if (noChild)
            {
                var borderHeight = (int)(this.borderThickness.Top + this.borderThickness.Bottom);
                var borderWidth = (int)(this.borderThickness.Left + this.borderThickness.Right);
                height = borderHeight > 0 ? borderHeight : canvas.ClipBounds.Bottom;
                width = borderWidth > 0 ? borderWidth : canvas.ClipBounds.Right;
            }
            shape.Resize(width, height);
            shape.Draw(canvas, strokepaint);

            var pathInner = new Path();
            var rect = new RectF(
                (float)(borderThickness.Left),
                (float)(borderThickness.Top),
                (float)(canvas.ClipBounds.Right - borderThickness.Right),
                (float)(canvas.ClipBounds.Bottom - borderThickness.Bottom));
            pathInner.AddRoundRect(rect, cornerRadiusArray, Path.Direction.Cw);
            if (!noChild)
            {
                var clearPaint = new Paint();
                clearPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.Clear));
                canvas.DrawPath(pathInner, clearPaint);
            }
            canvas.DrawPath(pathInner, fillpaint);
        }
开发者ID:evnik,项目名称:UIFramework,代码行数:29,代码来源:Border.Droid.cs

示例13: getRoundedCroppedBitmap

		public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {
			Bitmap finalBitmap;
			if (bitmap.Width != radius || bitmap.Height!= radius)
				finalBitmap = Bitmap.CreateScaledBitmap(bitmap, radius, radius,
					false);
			else
				finalBitmap = bitmap;
			Bitmap output = Bitmap.CreateBitmap(finalBitmap.Width,
				finalBitmap.Height, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(output);

			 Paint paint = new Paint();
			Rect rect = new Rect(0, 0, finalBitmap.Width,
				finalBitmap.Height);

			paint.AntiAlias=true;
			paint.FilterBitmap=true;
			paint.Dither=true;
			canvas.DrawARGB(0, 0, 0, 0);
			paint.Color=Color.ParseColor("#BAB399");
			canvas.DrawCircle(finalBitmap.Width / 2 + 0.7f,
				finalBitmap.Height / 2 + 0.7f,
				finalBitmap.Width / 2 + 0.1f, paint);
			paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
			canvas.DrawBitmap(finalBitmap, rect, rect, paint);

			return output;
		}	
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:28,代码来源:RoundedImageView.cs

示例14: loadProfilePicture

        private void loadProfilePicture(Guid contactId)
        {
            if (contactId != null) {
                ContactDB cont = new ContactDB ();
                if (contacts.ContainsKey (contactId))
                    cont = contacts [contactId];

                byte[] imgdata = cont.ContactUser.Picture;
                Bitmap original = BitmapFactory.DecodeByteArray (imgdata, 0, imgdata.Length);
                Bitmap mask = Bitmap.CreateScaledBitmap (BitmapFactory.DecodeResource (Resources, Resource.Drawable.emptybackground), original.Width, original.Height, true);
                Bitmap result = Bitmap.CreateBitmap (mask.Width, mask.Height, Bitmap.Config.Argb8888);
                Canvas canv = new Canvas (result);
                Paint paint = new Paint (PaintFlags.AntiAlias);

                paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.DstIn));
                canv.DrawBitmap (original, 0, 0, null);
                canv.DrawBitmap (mask, 0, 0, paint);
                paint.SetXfermode (null);

                RunOnUiThread (delegate {
                    ImageView pic = (ImageView)converse.FindViewWithTag (new Java.Lang.String ("profilepic_" + contactId.ToString ()));
                    pic.SetImageBitmap (result);
                    original.Dispose ();
                    mask.Dispose ();
                    paint.Dispose ();
                    canv.Dispose ();
                    result.Dispose ();
                });
            }
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:30,代码来源:ConversationActivity.cs

示例15: SetHardwareAccelerated

        public void SetHardwareAccelerated(bool accelerated)
        {
            if (accelerated)
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
                {
                    if (IsHardwareAccelerated)
                    {
                        var hardwarePaint = new Paint();
                        hardwarePaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.Overlay));

                        SetLayerType(LayerType.Hardware, hardwarePaint);
                    }
                    else
                    {
                        SetLayerType(LayerType.Software, null);
                    }
                }
                else
                {
                    DrawingCacheEnabled = true;
                }
            }
            else
            {
                if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
                {
                    SetLayerType(LayerType.Software, null);
                }
                else
                {
                    DrawingCacheEnabled = true;
                }
            }
        }
开发者ID:andyci,项目名称:ShowcaseView,代码行数:35,代码来源:ShowcaseView.cs


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