本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}