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


C# Drawable.Draw方法代码示例

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


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

示例1: LoadPiece

        public void LoadPiece(PieceType type, Drawable piece)
        {
            Bitmap bitmap = Bitmap.CreateBitmap (piece_size, piece_size, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas (bitmap);

            piece.SetBounds (0, 0, piece_size, piece_size);
            piece.Draw (canvas);

            piece_bitmaps[(int)type] = bitmap;
        }
开发者ID:Hackemate,项目名称:Snake,代码行数:10,代码来源:PieceView.cs

示例2: LoadTile

		// Function to set the specified Drawable as the tile for a particular
		// integer key.
		public void LoadTile (TileType type, Drawable tile)
		{
			Bitmap bitmap = Bitmap.CreateBitmap (tile_size, tile_size, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas (bitmap);

			tile.SetBounds (0, 0, tile_size, tile_size);
			tile.Draw (canvas);

			tile_bitmaps[(int)type] = bitmap;
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:12,代码来源:TileView.cs

示例3: DrawableToBitmap

		public static Bitmap DrawableToBitmap(Drawable drawable)
		{
			if (drawable is BitmapDrawable)
			{
				return ((BitmapDrawable)drawable).Bitmap;
			}

			if (drawable.IntrinsicHeight == -1 || drawable.IntrinsicHeight == -1)
				return null;

			Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(bitmap);
			drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
			drawable.Draw(canvas);

			return bitmap;
		}
开发者ID:gxy001,项目名称:Office365-FiveMinuteMeeting,代码行数:17,代码来源:Utils.cs

示例4: DrawAt

        protected void DrawAt(Canvas canvas, Drawable drawable, int x, int y, bool shadow)
        {
            try
            {
                canvas.Save();
                canvas.Translate(x, y);
                if (shadow)
                {
                    drawable.SetColorFilter(Util.Int32ToColor(2130706432), PorterDuff.Mode.SrcIn);
                    canvas.Skew(-0.9F, 0.0F);
                    canvas.Scale(1.0F, 0.5F);
                }

                drawable.Draw(canvas);
                if (shadow)
                {
                    drawable.ClearColorFilter();
                }
            }
            finally
            {
                canvas.Restore();
            }
        }
开发者ID:knji,项目名称:mvvmcross.plugins,代码行数:24,代码来源:Style.cs

示例5: DrawableToBitmap

        /**
         * Convert a drawable object into a Bitmap.
         * @param drawable Drawable to extract a Bitmap from.
         * @return A Bitmap created from the drawable parameter.
         */
        public Bitmap DrawableToBitmap(Drawable drawable)
        {
            if (drawable == null)   // Don't do anything without a proper drawable
                return null;
            else if (drawable.GetType() == typeof(BitmapDrawable))    // Use the getBitmap() method instead if BitmapDrawable
                return ((BitmapDrawable)drawable).Bitmap;

            // Create Bitmap object out of the drawable
            Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(bitmap);
            drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            drawable.Draw(canvas);

            // Return the created Bitmap
            return bitmap;
        }
开发者ID:EckyZero,项目名称:Hashtagg,代码行数:21,代码来源:CircularImageView.cs

示例6: drawableToBitmap

		public virtual Bitmap drawableToBitmap(Drawable drawable)
		{
			if (drawable == null)
			{
				return null;
			}
			else if (drawable is BitmapDrawable)
			{
				return ((BitmapDrawable)drawable).Bitmap;
			}

			Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
			Canvas canvas = new Canvas(bitmap);
			drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
			drawable.Draw(canvas);

			return bitmap;
		}
开发者ID:scrafty614,项目名称:XamarinStudio_Example,代码行数:18,代码来源:CircleImageView.cs

示例7: DrawableToBitmap

        public static Bitmap DrawableToBitmap(Drawable drawable)
        {
            var bitmapDrawable = drawable as BitmapDrawable;
            if (bitmapDrawable != null)
            {
                return bitmapDrawable.Bitmap;
            }

            Bitmap bitmap;
            int width = Math.Max(drawable.IntrinsicWidth, 1);
            int height = Math.Max(drawable.IntrinsicHeight, 1);
            try
            {
                bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
                var canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
            }
            catch (Exception)
            {
                bitmap = null;
            }

            return bitmap;
        }
开发者ID:herrskytte,项目名称:RoundedImageView,代码行数:25,代码来源:RoundedDrawable.cs

示例8: getBitmapFromDrawable

        private Bitmap getBitmapFromDrawable(Drawable drawable)
        {
            if (drawable == null)
            {
                return null;
            }

            if (drawable is BitmapDrawable)
            {
                return ((BitmapDrawable)drawable).Bitmap;
            }

            try
            {
                Bitmap bitmap;

                if (drawable is ColorDrawable)
                {
                    bitmap = Bitmap.CreateBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
                }
                else {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, BITMAP_CONFIG);
                }

                Canvas canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return bitmap;
            }
            catch
            { //catch (OutOfMemoryException e) {
                return null;
            }
        }
开发者ID:takigava,项目名称:pikabu,代码行数:34,代码来源:CircleImageView.cs

示例9: DrawableToBitmap

        private Bitmap DrawableToBitmap(Drawable drawable)
        {
            try
            {
                if (drawable is BitmapDrawable)
                    return ((BitmapDrawable)drawable).Bitmap;

                Bitmap bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, Bitmap.Config.Argb8888);
                Canvas canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);

                return bitmap;
            }
            catch (Exception ex)
            {
                //FirstLog.Error(FirstApplication.ApplicationName + "Log", "ResizeBitmap: " + ex.Message);
                return null;
            }
        }
开发者ID:gsoldav,项目名称:Android-Xamarin,代码行数:20,代码来源:CheckBoxExtended.cs

示例10: GetBitmapFromDrawable

        private Bitmap GetBitmapFromDrawable(Drawable drawable)
        {
            if (drawable == null)
            {
                return null;
            }

            var bitmapDrawable = drawable as BitmapDrawable;
            if (bitmapDrawable != null)
            {
                return bitmapDrawable.Bitmap;
            }

            try
            {
                Bitmap bitmap;

                if (drawable is ColorDrawable)
                {
                    bitmap = Bitmap.CreateBitmap(ColordrawableDimension, ColordrawableDimension, BitmapConfig);
                }
                else
                {
                    bitmap = Bitmap.CreateBitmap(drawable.IntrinsicWidth, drawable.IntrinsicHeight, BitmapConfig);
                }

                var canvas = new Canvas(bitmap);
                drawable.SetBounds(0, 0, canvas.Width, canvas.Height);
                drawable.Draw(canvas);
                return bitmap;
            }
            catch (OutOfMemoryException)
            {
                return null;
            }
        }
开发者ID:blocke79,项目名称:CircleImageView-Xamarin,代码行数:36,代码来源:CircleImageView.cs

示例11: LoadObject

        public void LoadObject(GameObjects type, Drawable tile)
        {
            Bitmap bitmap = Bitmap.CreateBitmap (objectSize, objectSize, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas (bitmap);

            tile.SetBounds (0, 0, objectSize, objectSize);
            tile.Draw (canvas);

            bitmaps [(int)type] = bitmap;
        }
开发者ID:adlair,项目名称:Projects,代码行数:10,代码来源:Helper.cs


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