本文整理汇总了C#中Android.Graphics.Paint.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Paint.Dispose方法的具体用法?C# Paint.Dispose怎么用?C# Paint.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Paint
的用法示例。
在下文中一共展示了Paint.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeImages
private void InitializeImages()
{
if(_pressedImage != null)
{
_pressedImage.Recycle();
_pressedImage.Dispose();
}
if(_unpressedImage != null)
{
_unpressedImage.Recycle();
_unpressedImage.Dispose();
}
_unpressedImage = Bitmap.CreateBitmap(Width, Settings.IsSquared ? Width : Height, Bitmap.Config.Argb8888);
_pressedImage = Bitmap.CreateBitmap(Width, Settings.IsSquared ? Width : Height, Bitmap.Config.Argb8888);
Canvas unpressedCanvas = new Canvas(_unpressedImage);
Canvas pressedCanvas = new Canvas(_pressedImage);
Settings.SetTextSize(ComplexUnitType.Px, Settings.TextSize == 0f ? Height * Settings.TextSizeRatio : Settings.TextSize);
Settings.StrokeBorderWidth = Height * Settings.StrokeBorderWidthRatio;
Settings.StrokeTextWidth = Height * Settings.StrokeTextWidthRatio;
// Background fill paint
Paint fillBackPaint = new Paint();
fillBackPaint.Color = Settings.FillColor;
fillBackPaint.AntiAlias = true;
// Background stroke paint
Paint strokeBackPaint = new Paint();
strokeBackPaint.Color = Settings.StrokeColor;
strokeBackPaint.SetStyle(Paint.Style.Stroke);
strokeBackPaint.StrokeWidth = Settings.StrokeBorderWidth;
strokeBackPaint.AntiAlias = true;
// Text paint
Paint textPaint = new Paint();
textPaint.Color = Settings.IsTextStroked ? Settings.FillColor : Settings.StrokeColor;
textPaint.TextAlign = Paint.Align.Center;
textPaint.TextSize = Settings.TextSize;
textPaint.SetTypeface(Settings.Typeface);
textPaint.AntiAlias = true;
// Text stroke paint
Paint strokePaint = new Paint();
strokePaint.Color = Settings.StrokeColor;
strokePaint.TextAlign = Paint.Align.Center;
strokePaint.TextSize = Settings.TextSize;
strokePaint.SetTypeface(Settings.Typeface);
strokePaint.SetStyle(Paint.Style.Stroke);
strokePaint.StrokeWidth = Settings.StrokeTextWidth;
strokePaint.AntiAlias = true;
// Background bounds
Rect local = new Rect();
this.GetLocalVisibleRect(local);
RectF bounds = new RectF(local);
bounds.Top += Settings.StrokeBorderWidth/2;
bounds.Left += Settings.StrokeBorderWidth/2;
bounds.Right -= Settings.StrokeBorderWidth/2;
bounds.Bottom -= Settings.StrokeBorderWidth/2;
while(bounds.Top > Height)
{
bounds.Top -= Height;
}
while(bounds.Bottom > Height)
{
bounds.Bottom -= Height;
}
while(bounds.Left > Width)
{
bounds.Left -= Width;
}
while(bounds.Right > Width)
{
bounds.Right -= Width;
}
// Text location
Rect r = new Rect();
strokePaint.GetTextBounds(Text, 0, Text.Length, r);
while(r.Width() + Settings.StrokeTextWidth >= bounds.Width())
{
Settings.SetTextSize(ComplexUnitType.Px, Settings.TextSize-1);
textPaint.TextSize = Settings.TextSize;
strokePaint.TextSize = Settings.TextSize;
strokePaint.GetTextBounds(Text, 0, Text.Length, r);
}
float x=0, y=0;
switch (Settings.Gravity)
{
case GravityFlags.Top:
y = PaddingTop + r.Height()/2;
break;
case GravityFlags.Bottom:
y = Height - r.Height()/2 - PaddingBottom;
break;
default:
y = Height / 2f + r.Height() / 2f - r.Bottom;
//.........这里部分代码省略.........