本文整理汇总了C#中Android.Graphics.Drawables.Drawable.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Drawable.SetBounds方法的具体用法?C# Drawable.SetBounds怎么用?C# Drawable.SetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Drawables.Drawable
的用法示例。
在下文中一共展示了Drawable.SetBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GestureRecognizerView
public GestureRecognizerView (Context context)
: base(context, null, 0)
{
_icon = context.Resources.GetDrawable (Resource.Drawable.ic_launcher);
_icon.SetBounds (0, 0, _icon.IntrinsicWidth, _icon.IntrinsicHeight);
_scaleDetector = new ScaleGestureDetector (context, new MyScaleListener (this));
}
示例2: 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;
}
示例3: OnLoaded
public void OnLoaded(ImageView p0, Bitmap p1, string p2, bool p3)
{
_image = imageView.Drawable;
_image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);
_scaleDetector = new ScaleGestureDetector(_context, new MyScaleListener(this));
var metrics = Resources.DisplayMetrics;
_posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
_posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
}
示例4: 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;
}
示例5: MyDragShadowBuilder
public MyDragShadowBuilder(View v)
: base (v)
{
TypedArray a = v.Context.ObtainStyledAttributes (Resource.Styleable.AppTheme);
mShadow = a.GetDrawable (Resource.Styleable.AppTheme_listDragShadowBackground);
mShadow.Callback = v;
mShadow.SetBounds (0, 0, v.Width, v.Height);
a.Recycle ();
}
示例6: 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;
}
示例7: GestureRecognizerView
public GestureRecognizerView(Context context, String imageUrl)
: base(context, null, 0)
{
_context = context;
imageView = new ImageView(context);
Koush.UrlImageViewHelper.SetUrlDrawable(imageView, imageUrl, Resource.Drawable.placeholder, this);
_image = imageView.Drawable;
_image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);
//_scaleDetector = new ScaleGestureDetector(context, new MyScaleListener(this));
//var metrics = Resources.DisplayMetrics;
//_posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
//_posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: SetAlignment
public static Drawable SetAlignment(Drawable drawable, int bitset)
{
if (drawable != null)
{
int w = drawable.IntrinsicWidth;
int h = drawable.IntrinsicHeight;
int l = -(w >> 1);
int r = l + w;
int t = -(h >> 1);
int b = t + h;
int count = 0;
while ((bitset != 0) && (count++ < 3))
{
if ((bitset & 0x1) > 0)
{
l = -(w >> 1);
r = l + w;
bitset ^= 0x1;
}
else if ((bitset & 0x2) > 0)
{
t = -(h >> 1);
b = t + h;
bitset ^= 0x2;
}
else if ((bitset & 0x20) > 0)
{
t = -h;
b = 0;
bitset ^= 0x20;
}
else if ((bitset & 0x10) > 0)
{
t = 0;
b = h;
bitset ^= 0x10;
}
else if ((bitset & 0x8) > 0)
{
r = 0;
l = -w;
bitset ^= 0x8;
}
else if ((bitset & 0x4) > 0)
{
l = 0;
r = w;
bitset ^= 0x4;
}
}
drawable.SetBounds(l, t, r, b);
}
return drawable;
}
示例12: 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;
}
示例13: InitializeBuildingMarker
private void InitializeBuildingMarker()
{
_buildingMarker = Resources.GetDrawable(Resource.Drawable.building_medium);
_buildingMarker.SetBounds(0, 0, _buildingMarker.IntrinsicWidth, _buildingMarker.IntrinsicHeight);
}
示例14: 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;
}
}
示例15: 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;
}
}