public override void Draw(Canvas canvas) { var box = Element as RoundBoxView; var rect = new Rect(); var color = box.BorderColor != Color.White ? box.BorderColor.ToAndroid() : box.BackgroundColor.ToAndroid(); var paint = new Paint { Color = color, AntiAlias = true }; GetDrawingRect(rect); var radius = (float)(rect.Width() / 14 * 8); // ... / box width * box corner radius canvas.DrawRoundRect(new RectF(rect), radius, radius, paint); if (box.BorderThickness <= 0) { return; } var diameter = rect.Width() - box.BorderThickness; var rect1 = new Rect(box.BorderThickness, box.BorderThickness, diameter, diameter); var paint1 = new Paint { Color = box.BackgroundColor.ToAndroid(), AntiAlias = true }; canvas.DrawRoundRect(new RectF(rect1), radius, radius, paint1); }
/// <summary> /// This method will determine the scaling ratio for the image view. /// </summary> /// <param name="startBounds">The visible rectangle of the thumbnail.</param> /// <param name="finalBounds">The visible rectangle of the expanded image view.</param> /// <returns></returns> private static float CalculateStartScale(Rect startBounds, Rect finalBounds) { float startScale; // First figure out width-to-height ratio of each rectangle. float finalBoundsRatio = finalBounds.Width() / (float)finalBounds.Height(); float startBoundsRatio = startBounds.Width() / (float)startBounds.Height(); if (finalBoundsRatio > startBoundsRatio) { // Extend start bounds horizontally startScale = (float)startBounds.Height() / finalBounds.Height(); float startWidth = startScale * finalBounds.Width(); float deltaWidth = (startWidth - startBounds.Width()) / 2; startBounds.Left -= (int)deltaWidth; startBounds.Right += (int)deltaWidth; } else { // Extend start bounds vertically startScale = (float)startBounds.Width() / finalBounds.Width(); float startHeight = startScale * finalBounds.Height(); float deltaHeight = (startHeight - startBounds.Height()) / 2; startBounds.Top -= (int)deltaHeight; startBounds.Bottom += (int)deltaHeight; } return startScale; }
protected override void OnDraw(Canvas canvas) { base.OnDraw (canvas); var r = new Rect (); this.GetLocalVisibleRect (r); var half = r.Width() / 2; var height = r.Height(); var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit; var paint = new Paint() { Color = this.CurrentValue < 0 ? this.negativeColor : this.positiveColor, StrokeWidth = 5 }; paint.SetStyle(Paint.Style.Fill); if (this.CurrentValue < 0) { var start = (float)percentage * half; var size = half - start; canvas.DrawRect (new Rect ((int)start, 0, (int)(start + size), height), paint); } else { canvas.DrawRect (new Rect((int)half, 0, (int)(half + percentage * half), height), paint); } }
public override void Draw(Canvas canvas) { RoundedBoxView rbv = (RoundedBoxView)this.Element; Rect rc = new Rect(); GetDrawingRect(rc); Rect interior = rc; interior.Inset((int)rbv.BorderThickness, (int)rbv.BorderThickness); Paint p = new Paint() { Color = rbv.BackgroundColor.ToAndroid(), AntiAlias = true, }; var radius = (float)(rc.Width() / rbv.Width * rbv.CornerRadius); //canvas.DrawRoundRect(new RectF(interior), (float)rbv.CornerRadius, (float)rbv.CornerRadius, p); canvas.DrawRoundRect(new RectF(interior), radius, radius, p); // Draw border if (rbv.BorderThickness > 0) { p.Color = rbv.BorderColor.ToAndroid(); p.StrokeWidth = (float)rbv.BorderThickness; p.SetStyle(Paint.Style.Stroke); //canvas.DrawRoundRect(new RectF(rc), (float)rbv.CornerRadius, (float)rbv.CornerRadius, p); canvas.DrawRoundRect(new RectF(rc), radius, radius, p); } }
public Bitmap GetBitmapMarker(Context mContext, int resourceId, string text) { Resources resources = mContext.Resources; float scale = resources.DisplayMetrics.Density; Bitmap bitmap = BitmapFactory.DecodeResource(resources, resourceId); Bitmap.Config bitmapConfig = bitmap.GetConfig(); // set default bitmap config if none if (bitmapConfig == null) bitmapConfig = Bitmap.Config.Argb8888; bitmap = bitmap.Copy(bitmapConfig, true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(PaintFlags.AntiAlias); paint.Color = global::Android.Graphics.Color.Black; paint.TextSize = ((int)(14 * scale)); paint.SetShadowLayer(1f, 0f, 1f, global::Android.Graphics.Color.White); // draw text to the Canvas center Rect bounds = new Rect(); paint.GetTextBounds(text, 0, text.Length, bounds); int x = (bitmap.Width - bounds.Width()) / 2; int y = (bitmap.Height + bounds.Height()) / 2 - 20; canvas.DrawText(text, x, y, paint); return bitmap; }
public override void Draw(Canvas canvas) { LoadResources (); var blackPaint = new Paint () { Color = black.Value }; var whitePaint = new Paint () { Color = white.Value }; XamGame.RenderBoard ((RectangleF rect, Square.ColourNames color) => { var paint = color == Square.ColourNames.White ? whitePaint : blackPaint; canvas.DrawRect (rect.X, rect.Y, rect.Right, rect.Bottom, paint); }, (RectangleF rect, object image) => { if (image != null) canvas.DrawBitmap ((Bitmap) image, rect.Left, rect.Top, null); }); // New Game button whitePaint.Color = white.Value; whitePaint.SetStyle (Paint.Style.Fill); whitePaint.TextSize = 30; whitePaint.AntiAlias = true; Rect bounds = new Rect (); whitePaint.GetTextBounds ("New Game", 0, 8, bounds); canvas.DrawText ("New Game", (this.Width - bounds.Width ()) / 2, this.Bottom - (XamGame.BoardUpperLeftCorner.Y - bounds.Height ()) / 2, whitePaint); whitePaint.Dispose (); blackPaint.Dispose (); base.Draw (canvas); }
protected override void OnBoundsChange (Rect bounds) { base.OnBoundsChange (bounds); if (oval == null) return; oval.Set (0, 0, bounds.Width (), bounds.Height ()); }
internal void DrawText(string text, Paint p, Typeface font, float size, Rectangle rect, ReoGridHorAlign halign, ReoGridVerAlign valign) { p.SetTypeface(font); p.TextSize = size; var measuredRect = new Rect(); p.GetTextBounds(text, 0, text.Length, measuredRect); float x = rect.Left, y = rect.Top; switch (halign) { case ReoGridHorAlign.General: case ReoGridHorAlign.Left: x = rect.Left; break; case ReoGridHorAlign.Center: x = rect.Left + (rect.Width - measuredRect.Width()) / 2; break; case ReoGridHorAlign.Right: x = rect.Right - measuredRect.Width(); break; } switch (valign) { case ReoGridVerAlign.Top: y = rect.Top + measuredRect.Height(); break; case ReoGridVerAlign.Middle: y = rect.Bottom - (rect.Height - measuredRect.Height()) / 2; break; case ReoGridVerAlign.General: case ReoGridVerAlign.Bottom: y = rect.Bottom; break; } this.canvas.DrawText(text, x, y, p); }
protected override void OnBoundsChange (Rect bounds) { var width = bounds.Width (); var height = bounds.Height (); if (width <= 0 || height <= 0) return; if (Picture != null && (currentBitmap == null || currentBitmap.Height != height || currentBitmap.Width != width)) currentBitmap = SvgFactory.MakeBitmapFromPicture(Picture, width, height); }
public Size Measure(FormattedText formattedText) { var paint = new Paint(); var rect = new Rect(); paint.GetTextBounds(formattedText.Text, 0, formattedText.Text.Length, rect); return(new Size(rect.Width(), rect.Height())); }
protected override void OnBoundsChange (Rect bounds) { base.OnBoundsChange (bounds); int height = bounds.Height(); int width = bounds.Width(); numRectanglesHorizontal = (int) Math.Ceiling((double)(width / mRectangleSize)); numRectanglesVertical = (int) Math.Ceiling((double)height / mRectangleSize); generatePatternBitmap(); }
/// <summary> /// get the native width of the string /// </summary> /// <param name="text">the string to measure</param> /// <param name="fontSize">the font size of the displayed string</param> /// <returns>the width of the measured string</returns> public static double TextWidthNative(string text, float fontSize) { Graphics.Rect bounds = new Graphics.Rect(); TextView textView = new TextView(Native.Application.Context) { TextSize = fontSize }; textView.Paint.GetTextBounds(text.ToCharArray(), 0, text.Length, bounds); var length = bounds.Width(); return(length / Resources.System.DisplayMetrics.ScaledDensity); }
protected override void OnLayout (bool changed, int l, int t, int r, int b) { base.OnLayout (changed, l, t, r, b); if (changed) { var drawables = Control.GetCompoundDrawables (); if (drawables [0] != null) { Rect drawableBounds = new Rect (); drawables [0].CopyBounds (drawableBounds); int leftOffset = ((Control.Width - Control.PaddingLeft - Control.PaddingRight) - drawableBounds.Width ()) / 2; drawableBounds.Offset (leftOffset, 0); drawables [0].SetBounds (drawableBounds.Left, drawableBounds.Top, drawableBounds.Right, drawableBounds.Bottom); } } }
public override void Draw(Canvas canvas) { var box = Element as RoundedBox; var rect = new Rect(); var paint = new Paint() { Color = box.BackgroundColor.ToAndroid(), AntiAlias = true, }; GetDrawingRect(rect); var radius = (float)(rect.Width() / box.Width * box.CornerRadius); canvas.DrawRoundRect(new RectF(rect), radius, radius, paint); }
public Size Measure(FormattedText formattedText) { var paint = new Paint(); var rect = new Rect(); paint.TextSize = formattedText.FontSize; paint.GetTextBounds(formattedText.Text, 0, formattedText.Text.Length, rect); var descent = paint.Descent(); var height = rect.Height(); var width = rect.Width(); return(new Size(width, height + descent)); }
public SizeF MeasureString(Font font, string text) { if (string.IsNullOrEmpty(text)) // needed to avoid exception { return(SizeF.Empty); } var paint = GetTextPaint(font); // See http://stackoverflow.com/questions/7549182/android-paint-measuretext-vs-gettextbounds var bounds = new ag.Rect(); paint.GetTextBounds(text, 0, text.Length, bounds); // TODO: see the above article; the width may be truncated to the nearest integer. return(new SizeF(bounds.Width(), bounds.Height())); }
public override void Draw(Canvas canvas) { var box = Element as CustomRoundedBox; var rect = new Rect(); var paint = new Paint { AntiAlias = true, }; paint.SetARGB((int)box.BackgroundColor.A, (int)box.BackgroundColor.R, (int)box.BackgroundColor.G, (int)box.BackgroundColor.B); GetDrawingRect(rect); var radius = (float)(rect.Width() / box.Width * box.CornerRadius); canvas.DrawRoundRect(new RectF(rect), radius, radius, paint); }
public override void Draw(Canvas canvas) { var box = Element as RoundedBox; var rect = new Rect(); var androidColor = box.BackgroundColor.ToAndroid(); var paint = new Paint() { AntiAlias = true, }; paint.SetARGB(Convert.ToInt32(box.Opacity * 255), (int)androidColor.R, (int)androidColor.G, (int)androidColor.B); GetDrawingRect(rect); var radius = (float)(rect.Width() / box.Width * box.CornerRadius); canvas.DrawRoundRect(new RectF(rect), radius, radius, paint); }
protected override void OnBoundsChange (Rect bounds) { base.OnBoundsChange (bounds); mRect.Set (margin, margin, bounds.Width () - margin, bounds.Height () - margin); if (useGradientOverlay) { var colors = new int[] { 0, 0, 0x20000000 }; var pos = new float[] { 0.0f, 0.7f, 1.0f }; RadialGradient vignette = new RadialGradient (mRect.CenterX (), mRect.CenterY () * 1.0f / 0.7f, mRect.CenterX () * 1.3f, colors, pos, Shader.TileMode.Clamp); Matrix oval = new Matrix (); oval.SetScale (1.0f, 0.7f); vignette.SetLocalMatrix (oval); paint.SetShader (new ComposeShader (bitmapShader, vignette, PorterDuff.Mode.SrcOver)); } }
public float ButtonTextSize(string text, double fontSize) { if (_button == null) { _button = new global::Android.Widget.Button(Forms.Context); // _button.SetPadding(10, _button.PaddingTop, 10, _button.PaddingBottom); _button.SetPadding(0, _button.PaddingTop, 0, _button.PaddingBottom); } if (fontSize != 0) { _button.TextSize = (float)fontSize; } var widgetPadding = 8; var bounds = new Rect(); _button.Text = text; _button.Paint.GetTextBounds(text, 0, text.Length, bounds); // Add two times the widgetPadding of 8 dp, because the button has this min size and than resize to the next multi of 8. // http://developer.android.com/guide/practices/ui_guidelines/widget_design.html return (float)Math.Ceiling((bounds.Width() / Resources.System.DisplayMetrics.Density + _button.PaddingLeft + _button.PaddingRight + 2 * widgetPadding) / 8) * 8; }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Begin building a new dialog. var builder = new AlertDialog.Builder(Activity); Rect displayRectangle = new Rect(); Window window = Activity.Window; window.DecorView.GetWindowVisibleDisplayFrame(displayRectangle); var inflater = Activity.LayoutInflater; dateView = inflater.Inflate(Resource.Layout.DateRange, null); dateView.SetMinimumHeight((int)(displayRectangle.Width() * 0.9f)); dateView.SetMinimumHeight((int)(displayRectangle.Height() * 0.9f)); Button butOk = dateView.FindViewById<Button> (Resource.Id.butok); butOk.Click+= ButOk_Click; datePicker1 = DatePicker.NewInstance(SetDateDlg1); datePicker2 = DatePicker.NewInstance(SetDateDlg2); EditText frd = dateView.FindViewById<EditText> (Resource.Id.trxdatefr); EditText tod = dateView.FindViewById<EditText> (Resource.Id.trxdateto); frd.Text = DateTime.Today.ToString ("dd-MM-yyyy"); frd.Click += delegate(object sender, EventArgs e) { datePicker1.Show(FragmentManager, "datePicker"); }; tod.Text = DateTime.Today.ToString ("dd-MM-yyyy"); tod.Click += delegate(object sender, EventArgs e) { datePicker2.Show(FragmentManager, "datePicker2"); }; builder.SetView (dateView); builder.SetPositiveButton ("CANCEL", HandlePositiveButtonClick); var dialog = builder.Create(); //Now return the constructed dialog to the calling activity return dialog; }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); if (Control.GetCompoundDrawables() != null && BaseElement.CenterImage) { var text = Control.Text; int iconTextSpacing = 0; if (!string.IsNullOrWhiteSpace(text)) { TextPaint textPaint = Control.Paint; textPaint.GetTextBounds(text, 0, text.Length, textBounds); iconTextSpacing = 20; } else { textBounds.SetEmpty(); } int width = Control.Width - (Control.PaddingLeft + Control.PaddingRight); Drawable[] drawables = Control.GetCompoundDrawables(); if (drawables[0] != null) { drawables[0].CopyBounds(drawableBounds); int leftOffset = (width - (textBounds.Width() + drawableBounds.Width())) / 2 - Control.CompoundDrawablePadding - iconTextSpacing; if (drawableBounds.Left == 0 && drawableBounds.Left != leftOffset) { drawableBounds.Offset(leftOffset, 0); drawables[0].SetBounds(drawableBounds.Left, drawableBounds.Top, drawableBounds.Right, drawableBounds.Bottom); } } if (drawables[2] != null) { drawables[2].CopyBounds(drawableBounds); int rightOffset = ((textBounds.Width() + drawableBounds.Width()) - width) / 2 + Control.CompoundDrawablePadding + iconTextSpacing; if (drawableBounds.Left == 0 && drawableBounds.Right != rightOffset) { drawableBounds.Offset(rightOffset, 0); drawables[2].SetBounds(drawableBounds.Left, drawableBounds.Top, drawableBounds.Right, drawableBounds.Bottom); } } } //if (Control.GetCompoundDrawables() != null) //{ // if (BaseElement.CenterImage) // { // var imageRight = Control.GetCompoundDrawables()[2]; // if (imageRight != null) // { // var drawableBounds = new Android.Graphics.Rect(); // imageRight.CopyBounds(drawableBounds); // SetImagePadding(drawableBounds.Width()); // } // var imageLeft = Control.GetCompoundDrawables()[0]; // if (imageLeft != null) // { // var drawableBounds = new Android.Graphics.Rect(); // imageLeft.CopyBounds(drawableBounds); // SetImagePadding(drawableBounds.Width()); // } // } //} }
public static XIR.Rectangle RemoteRepresentation(this AG.Rect rectangle) => new XIR.Rectangle( rectangle.Left, rectangle.Top, rectangle.Width(), rectangle.Height());
//Actual Draw of analogue niddle in Canvas which will show in watch surface public override void OnDraw(Canvas canvas, Rect bounds) { time.SetToNow (); int width = bounds.Width (); int height = bounds.Height (); // Draw the background, scaled to fit. if (backgroundScaledBitmap == null || backgroundScaledBitmap.Width != width || backgroundScaledBitmap.Height != height) { backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap, width, height, true /* filter */); } canvas.DrawColor (Color.Black); canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null); float centerX = width / 2.0f; float centerY = height / 2.0f; // Draw the ticks. float innerTickRadius = centerX - 10; float outerTickRadius = centerX; for (int tickIndex = 0; tickIndex < 12; tickIndex++) { float tickRot = (float)(tickIndex * Math.PI * 2 / 12); float innerX = (float)Math.Sin (tickRot) * innerTickRadius; float innerY = (float)-Math.Cos (tickRot) * innerTickRadius; float outerX = (float)Math.Sin (tickRot) * outerTickRadius; float outerY = (float)-Math.Cos (tickRot) * outerTickRadius; canvas.DrawLine (centerX + innerX, centerY + innerY, centerX + outerX, centerY + outerY, tickPaint); } float secRot = time.Second / 30f * (float)Math.PI; int minutes = time.Minute; float minRot = minutes / 30f * (float)Math.PI; float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI; float secLength = centerX - 20; float minLength = centerX - 40; float hrLength = centerX - 80; if (!IsInAmbientMode) { float secX = (float)Math.Sin (secRot) * secLength; float secY = (float)-Math.Cos (secRot) * secLength; canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint); } float minX = (float)Math.Sin (minRot) * minLength; float minY = (float)-Math.Cos (minRot) * minLength; canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint); float hrX = (float)Math.Sin (hrRot) * hrLength; float hrY = (float)-Math.Cos (hrRot) * hrLength; canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint); }
void DrawShadow(Canvas canvas) { if (_shadowCanvas == null) { _shadowCanvas = new Canvas(); } if (_shadowPaint == null) { _shadowPaint = new Android.Graphics.Paint { AntiAlias = true, Dither = true, FilterBitmap = true } } ; Graphics.Color solidColor = null; // If need to redraw shadow if (_invalidateShadow) { var viewHeight = _viewBounds.Height(); var viewWidth = _viewBounds.Width(); if (GetChildAt(0) is AView child) { if (viewHeight == 0) { viewHeight = child.MeasuredHeight; } if (viewWidth == 0) { viewWidth = child.MeasuredWidth; } } // If bounds is zero if (viewHeight != 0 && viewWidth != 0) { var bitmapHeight = viewHeight + MaximumRadius; var bitmapWidth = viewWidth + MaximumRadius; // Reset bitmap to bounds _shadowBitmap = Bitmap.CreateBitmap( bitmapWidth, bitmapHeight, Bitmap.Config.Argb8888 ); // Reset Canvas _shadowCanvas.SetBitmap(_shadowBitmap); _invalidateShadow = false; // Create the local copy of all content to draw bitmap as a // bottom layer of natural canvas. base.DispatchDraw(_shadowCanvas); // Get the alpha bounds of bitmap Bitmap extractAlpha = _shadowBitmap.ExtractAlpha(); // Clear past content content to draw shadow _shadowCanvas.DrawColor(Android.Graphics.Color.Black, PorterDuff.Mode.Clear); var shadowOpacity = (float)Shadow.Opacity; if (Shadow.Paint is LinearGradientPaint linearGradientPaint) { var linearGradientShaderFactory = PaintExtensions.GetLinearGradientShaderFactory(linearGradientPaint, shadowOpacity); _shadowPaint.SetShader(linearGradientShaderFactory.Resize(bitmapWidth, bitmapHeight)); } if (Shadow.Paint is RadialGradientPaint radialGradientPaint) { var radialGradientShaderFactory = PaintExtensions.GetRadialGradientShaderFactory(radialGradientPaint, shadowOpacity); _shadowPaint.SetShader(radialGradientShaderFactory.Resize(bitmapWidth, bitmapHeight)); } if (Shadow.Paint is SolidPaint solidPaint) { solidColor = solidPaint.ToColor(); #pragma warning disable CA1416 // https://github.com/xamarin/xamarin-android/issues/6962 _shadowPaint.Color = solidColor.WithAlpha(shadowOpacity).ToPlatform(); #pragma warning restore CA1416 } // Apply the shadow radius var radius = Shadow.Radius; if (radius <= 0) { radius = 0.01f; } if (radius > 100) { radius = MaximumRadius; } _shadowPaint.SetMaskFilter(new BlurMaskFilter(radius, BlurMaskFilter.Blur.Normal)); float shadowOffsetX = (float)Shadow.Offset.X; float shadowOffsetY = (float)Shadow.Offset.Y; if (Clip == null) { _shadowCanvas.DrawBitmap(extractAlpha, shadowOffsetX, shadowOffsetY, _shadowPaint); } else { var bounds = new Graphics.RectF(0, 0, canvas.Width, canvas.Height); var path = Clip.PathForBounds(bounds)?.AsAndroidPath(); path.Offset(shadowOffsetX, shadowOffsetY); _shadowCanvas.DrawPath(path, _shadowPaint); } // Recycle and clear extracted alpha extractAlpha.Recycle(); } else { // Create placeholder bitmap when size is zero and wait until new size coming up _shadowBitmap = Bitmap.CreateBitmap(1, 1, Bitmap.Config.Rgb565 !); } } // Reset alpha to draw child with full alpha if (solidColor != null) #pragma warning disable CA1416 // https://github.com/xamarin/xamarin-android/issues/6962 { _shadowPaint.Color = solidColor.ToPlatform(); } #pragma warning restore CA1416 // Draw shadow bitmap if (_shadowCanvas != null && _shadowBitmap != null && !_shadowBitmap.IsRecycled) { canvas.DrawBitmap(_shadowBitmap, 0.0F, 0.0F, _shadowPaint); } } void ClearShadowResources() { _shadowCanvas?.Dispose(); _shadowPaint?.Dispose(); _shadowBitmap?.Dispose(); _shadowCanvas = null; _shadowPaint = null; _shadowBitmap = null; } }
protected override void OnDraw(Canvas canvas) { if (Element != null && Element.Text != null) { var density = DeviceDisplay.MainDisplayInfo.Density; float strokeWidth = Convert.ToSingle(Element.StrokeWidth * density); float strokeMiter = 10.0f; var rect = new Android.Graphics.Rect(); this.GetDrawingRect(rect); float progressAngle = 360 * Convert.ToSingle(Element.Progress / Element.Total); float radius = Math.Min(rect.Height(), rect.Width()) / 2 - strokeWidth; RectF circleRect = new RectF( rect.ExactCenterX() - radius, rect.ExactCenterY() - radius, rect.ExactCenterX() + radius, rect.ExactCenterY() + radius ); TextPaint paint = new TextPaint(); paint.Color = Element.TextColor.ToAndroid(); paint.TextSize = Element.TextSize; paint.GetTextBounds(Element.Text.ToString(), 0, Element.Text.ToString().Length, rect); if (((this.Width / 2) - (Element.TextMargin * 4)) < rect.Width()) { float ratio = (float)((this.Width / 2) - Element.TextMargin * 4) / (float)rect.Width(); paint.TextSize = paint.TextSize * ratio; paint.GetTextBounds(Element.Text.ToString(), 0, Element.Text.ToString().Length, rect); } int x = this.Width / 2 - rect.CenterX(); int y = this.Height / 2 - rect.CenterY(); Paint progressPaint = new Paint(PaintFlags.AntiAlias) { StrokeWidth = strokeWidth, StrokeMiter = strokeMiter, Color = Element.ProgressStrokeColor.ToAndroid() }; progressPaint.SetStyle(Paint.Style.Stroke); Paint availablePaint = new Paint(PaintFlags.AntiAlias) { StrokeWidth = strokeWidth, StrokeMiter = strokeMiter, Color = Element.AvailableStrokeColor.ToAndroid() }; availablePaint.SetStyle(Paint.Style.Stroke); Paint paintCircle = new Paint(PaintFlags.AntiAlias) { Color = Element.FillColor.ToAndroid() }; canvas.DrawArc(circleRect, -90, progressAngle, false, progressPaint); canvas.DrawArc(circleRect, -90 + progressAngle, 360 - progressAngle, false, availablePaint); canvas.DrawText(Element.Text.ToString(), x, y, paint); } }
/// <summary> /// Implement this to do your drawing. /// </summary> /// <param name="canvas">the canvas on which the background will be drawn</param> /// <since version="Added in API level 1" /> /// <remarks> /// <para tool="javadoc-to-mdoc">Implement this to do your drawing.</para> /// <para tool="javadoc-to-mdoc"> /// <format type="text/html"> /// <a href="http://developer.android.com/reference/android/view/View.html#onDraw(android.graphics.Canvas)" /// target="_blank"> /// [Android Documentation] /// </a> /// </format> /// </para> /// </remarks> protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var r = new Rect(0, 0, canvas.Width, canvas.Height); var dAdjustedThicnkess = (float)Thickness * _dm; var paint = new Paint { Color = StrokeColor, StrokeWidth = dAdjustedThicnkess, AntiAlias = true }; paint.SetStyle(Paint.Style.Stroke); switch (StrokeType) { case StrokeType.Dashed: paint.SetPathEffect(new DashPathEffect(new[] { 6 * _dm, 2 * _dm }, 0)); break; case StrokeType.Dotted: paint.SetPathEffect(new DashPathEffect(new[] { dAdjustedThicnkess, dAdjustedThicnkess }, 0)); break; } var thicknessOffset = (dAdjustedThicnkess) / 2.0f; var p = new Path(); if (Orientation == SeparatorOrientation.Horizontal) { p.MoveTo(0, thicknessOffset); p.LineTo(r.Width(), thicknessOffset); } else { p.MoveTo(thicknessOffset, 0); p.LineTo(thicknessOffset, r.Height()); } canvas.DrawPath(p, paint); }
public void DrawText(Point p, string text, Color fill, string fontFamily = null, double fontSize = 10, double fontWeight = 500, double rotate = 0, HorizontalAlignment halign = HorizontalAlignment.Left, VerticalAlignment valign = VerticalAlignment.Top, Size? maxSize = new Size?()) { using (var paint = new Paint()) { paint.AntiAlias = true; paint.TextSize = (float)fontSize; paint.Color = fill; var bounds = new Rect(); paint.GetTextBounds(text, 0, text.Length, bounds); float dx = 0; if (halign == HorizontalAlignment.Center) { dx = -bounds.Width() / 2; } if (halign == HorizontalAlignment.Right) { dx = -bounds.Width(); } float dy = 0; if (valign == VerticalAlignment.Center) { dy = +bounds.Height() / 2; } if (valign == VerticalAlignment.Top) { dy = bounds.Height(); } canvas.Save(); canvas.Translate(dx, dy); canvas.Rotate((float)rotate); canvas.Translate((float)p.X, (float)p.Y); canvas.DrawText(text, 0, 0, paint); canvas.Restore(); } }
internal void Draw(Canvas canvas, bool isRound) { if (Hidden) { return; } canvas.Save(); var resizerPaint = new Paint { Color = new Color(255, 255, 255, 200) }; //if (!Focused) //{ // outlinePaint.Color = Color.White; // canvas.DrawRect(DrawRect, outlinePaint); // //canvas.DrawCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width(), resizerPaint); //} //else //{ Rect viewDrawingRect = new Rect(); context.GetDrawingRect(viewDrawingRect); outlinePaint.Color = Color.White;// new Color(0XFF, 0xFF, 0x8A, 0x00); focusPaint.Color = new Color(50, 50, 50, 125); Path path = new Path(); if (isRound) { path.AddCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width() / 2, Path.Direction.Cw); canvas.ClipPath(path, Region.Op.Difference); canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint); } else { path.AddRect(new RectF(DrawRect), Path.Direction.Cw); canvas.ClipPath(path, Region.Op.Difference); canvas.DrawRect(viewDrawingRect, focusPaint); } //canvas.ClipPath(path, Region.Op.Difference); //if (isRound) // canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint); //else // canvas.DrawRect(viewDrawingRect, focusPaint); canvas.Restore(); canvas.DrawPath(path, outlinePaint); var resizerTriangle = new Path(); var resizerOffset = 4; var triangleSize = resizerSize + resizerOffset; resizerTriangle.MoveTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - triangleSize); resizerTriangle.LineTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - resizerOffset); resizerTriangle.LineTo(DrawRect.Right - triangleSize, DrawRect.Bottom - resizerOffset); resizerPaint.SetStyle(Paint.Style.Fill); canvas.DrawPath(resizerTriangle, resizerPaint); if (isRound) { // Draw the rectangle around the round cropper var roundCropperRectangle = new Path(); roundCropperRectangle.MoveTo(DrawRect.Left, DrawRect.Top); roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Top); roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Bottom); roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Bottom); roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Top); resizerPaint.SetStyle(Paint.Style.Stroke); canvas.DrawPath(roundCropperRectangle, resizerPaint); } }
void DrawFace(Canvas canvas, Rect bounds) { var width = bounds.Width(); var height = bounds.Height(); // Draw the background, scaled to fit. if (backgroundScaledBitmap == null || backgroundScaledBitmap.Width != width || backgroundScaledBitmap.Height != height) { backgroundScaledBitmap = Bitmap.CreateScaledBitmap(backgroundBitmap, width, height, true /* filter */); } canvas.DrawColor(Color.Black); canvas.DrawBitmap(backgroundScaledBitmap, 0, 0, null); var centerX = width / 2.0f; var centerY = height / 2.0f; // Draw the ticks. var innerTickRadius = centerX - 10; var outerTickRadius = centerX; for (var tickIndex = 0; tickIndex < 12; tickIndex++) { var tickRot = (float)(tickIndex * Math.PI * 2 / 12); var innerX = (float)Math.Sin(tickRot) * innerTickRadius; var innerY = (float)-Math.Cos(tickRot) * innerTickRadius; var outerX = (float)Math.Sin(tickRot) * outerTickRadius; var outerY = (float)-Math.Cos(tickRot) * outerTickRadius; canvas.DrawLine(centerX + innerX, centerY + innerY, centerX + outerX, centerY + outerY, tickPaint); } }
public override void Draw(Canvas canvas) { _bounds = Bounds; canvas.ClipRect(_bounds); if (_reversed) { canvas.Translate(_bounds.Width(), 0); canvas.Scale(-1, 1); } DrawStrokes(canvas); }
protected override void OnBoundsChange(Rect bounds) { base.OnBoundsChange(bounds); mRectF.Set(0, 0, bounds.Width(), bounds.Height()); }
internal static Bitmap transform(Matrix scaler, Bitmap source, int targetWidth, int targetHeight, bool scaleUp) { int deltaX = source.Width - targetWidth; int deltaY = source.Height - targetHeight; if (!scaleUp && (deltaX < 0 || deltaY < 0)) { // In this case the bitmap is smaller, at least in one dimension, // than the target. Transform it by placing as much of the image // as possible into the target and leaving the top/bottom or // left/right (or both) black. Bitmap b2 = Bitmap.CreateBitmap(targetWidth, targetHeight, Bitmap.Config.Argb8888); Canvas c = new Canvas(b2); int deltaXHalf = Math.Max(0, deltaX / 2); int deltaYHalf = Math.Max(0, deltaY / 2); Rect src = new Rect( deltaXHalf, deltaYHalf, deltaXHalf + Math.Min(targetWidth, source.Width), deltaYHalf + Math.Min(targetHeight, source.Height)); int dstX = (targetWidth - src.Width()) / 2; int dstY = (targetHeight - src.Height()) / 2; Rect dst = new Rect( dstX, dstY, targetWidth - dstX, targetHeight - dstY); c.DrawBitmap(source, src, dst, null); return b2; } float bitmapWidthF = source.Width; float bitmapHeightF = source.Height; float bitmapAspect = bitmapWidthF / bitmapHeightF; float viewAspect = (float)targetWidth / targetHeight; if (bitmapAspect > viewAspect) { float scale = targetHeight / bitmapHeightF; if (scale < .9F || scale > 1F) { scaler.SetScale(scale, scale); } else { scaler = null; } } else { float scale = targetWidth / bitmapWidthF; if (scale < .9F || scale > 1F) { scaler.SetScale(scale, scale); } else { scaler = null; } } Bitmap b1; if (scaler != null) { // this is used for minithumb and crop, so we want to filter here. b1 = Bitmap.CreateBitmap(source, 0, 0, source.Width, source.Height, scaler, true); } else { b1 = source; } int dx1 = Math.Max(0, b1.Width - targetWidth); int dy1 = Math.Max(0, b1.Height - targetHeight); Bitmap b3 = Bitmap.CreateBitmap( b1, dx1 / 2, dy1 / 2, targetWidth, targetHeight); if (b1 != source) { b1.Recycle(); } return b3; }
public static Rectangle ToEto(this ag.Rect rect) { return(new Rectangle(rect.Left, rect.Top, rect.Width(), rect.Height())); }
private void DrawLetters(Canvas canvas) { Paint letterPaint = new Paint(); letterPaint.StrokeWidth = 1; letterPaint.SetStyle(Paint.Style.Stroke); int rectWidth = (int)(mViewInfo.Width / 11.0); int rectHeight = (int)(mViewInfo.Height / 11.0); letterPaint.TextSize = Math.Min(rectHeight, 80); for (int i = 0; i < 11; i++) { for (int j = 0; j < 11; j++) { letterPaint.SetStyle(Paint.Style.Stroke); //canvas.DrawRect(new Android.Graphics.Rect(i * rectWidth, j * rectHeight, (i + 1) * rectWidth, (j + 1) * rectHeight), paint); KeyValuePair <int, int> index = new KeyValuePair <int, int>(i, j); if (sSignatureLocations.ContainsKey(index)) { Signature sig = sSignatureLocations[index]; char chr = Arrangement.Layout[sig].Character; char chrToMeasure = chr == ' ' ? 'X' : chr; int x = i * rectWidth; int y = j * rectHeight; Android.Graphics.Rect rect = new Android.Graphics.Rect(x, y, x + rectWidth, y + rectHeight); // The actual character is used for horizontal positioning Android.Graphics.Rect characterBounds = new Android.Graphics.Rect(); letterPaint.GetTextBounds(chrToMeasure.ToString(), 0, 1, characterBounds); // A standard character is used for vertical positioning so all the characters line up Android.Graphics.Rect xBounds = new Android.Graphics.Rect(); letterPaint.GetTextBounds("X", 0, 1, xBounds); // Center the character in the rectangle int textLeft = rect.Left + (int)((rect.Width() - characterBounds.Width()) / 2.0); int textBottom = rect.Bottom - (int)((rect.Height() - xBounds.Width()) / 2.0); // Lift the bottom up away from the border if we're on the bottom row //int textBottom = rect.Bottom - (j == 10 ? 10 : 0); TinyTypeLib.Rect boundsInLocation = new TinyTypeLib.Rect(rect.Left, textBottom - xBounds.Height(), rect.Right, textBottom); if (sig == mViewInfo.CurrentSignature) { // Don't draw within the MiddleSquare canvas.ClipRect(new Android.Graphics.Rect(mViewInfo.Left, mViewInfo.Top, mViewInfo.Right, mViewInfo.Bottom)); Path cp = new Path(); cp.AddCircle(mViewInfo.MiddleSquare.Center.X, mViewInfo.MiddleSquare.Center.Y, mViewInfo.MiddleSquare.Width / 2f, Path.Direction.Cw); canvas.ClipPath(cp, Region.Op.Difference); //canvas.ClipRect(Converter.TinyTypeRectToAndroidRect(mViewInfo.MiddleSquare), Region.Op.Difference); int gradientSize = 20; Paint linePaint = new Paint(); // Draw a line to the circle we're about to draw Line lineToLetter = new Line(mViewInfo.MiddleSquare.Center, boundsInLocation.Center); Line perpendicular = lineToLetter.GetPerpendicular(gradientSize); Color color = GetPositionColor((Position)mViewInfo.CurrentSignature.StartHeading.Quadrant); Color transparent = AndroidUtil.GetTransparentColor(color); linePaint.SetShader(new LinearGradient(perpendicular.Start.X, perpendicular.Start.Y, perpendicular.End.X, perpendicular.End.Y, color, transparent, Shader.TileMode.Mirror)); linePaint.SetStyle(Paint.Style.Stroke); linePaint.StrokeWidth = gradientSize * 2; linePaint.StrokeCap = Paint.Cap.Round; canvas.DrawLine(lineToLetter.Start.X, lineToLetter.Start.Y, lineToLetter.End.X, lineToLetter.End.Y, linePaint); } else { //letterPaint.Color = new Color(255, 0, 255); } if (chr != char.MinValue) { // Fill a circle in the background of the circle Paint letterBackgroundPaint = new Paint(); Color letterBackgroundColor = GetPositionColor((Position)sig.StartQuadrant); Color letterBackgroundTransparent = AndroidUtil.GetTransparentColor(letterBackgroundColor); float radius = Math.Max(boundsInLocation.Width, boundsInLocation.Height) / 2f; letterBackgroundPaint.SetShader(new RadialGradient(boundsInLocation.Center.X, boundsInLocation.Center.Y, radius, letterBackgroundColor, letterBackgroundTransparent, Shader.TileMode.Mirror)); letterBackgroundPaint.SetStyle(Paint.Style.FillAndStroke); canvas.DrawCircle(boundsInLocation.Center.X, boundsInLocation.Center.Y, (float)(Math.Max(boundsInLocation.Width, boundsInLocation.Height) / 2.0), letterBackgroundPaint); letterPaint.SetStyle(Paint.Style.FillAndStroke); canvas.DrawText(chr.ToString(), textLeft, textBottom, letterPaint); } } } } letterPaint.SetStyle(Paint.Style.FillAndStroke); letterPaint.Color = GetPositionColor(Position.Middle); letterPaint.TextSize = mViewInfo.MiddleSquare.Height * 0.75f; Drawing.ClearClip(canvas, mViewInfo); // Draw the selected character in the middle of the square if (mViewInfo.CurrentSignature.Gesture == Signature.Gestures.Normal) { char chr = Arrangement.Layout[mViewInfo.CurrentSignature].Character; // Center the character in the rectangle Android.Graphics.Rect bounds = new Android.Graphics.Rect(); letterPaint.GetTextBounds(chr.ToString(), 0, 1, bounds); int textLeft = mViewInfo.MiddleSquare.Left + (int)((mViewInfo.MiddleSquare.Width - bounds.Width()) / 2.0); int textBottom = mViewInfo.MiddleSquare.Bottom - (int)((mViewInfo.MiddleSquare.Height - bounds.Height()) / 2.0); canvas.DrawText(chr.ToString(), textLeft, textBottom, letterPaint); } /* * // Draw the previous character above the center square * if (mPreviousCharacter != char.MinValue) * { * TinyTypeLib.Rect rect = mViewInfo.MiddleSquare.Offset(0, -mViewInfo.MiddleSquare.Height); * * //paint.SetStyle(Paint.Style.Stroke); * //canvas.DrawRect(Converter.TinyTypeRectToAndroidRect(rect), paint); * //paint.SetStyle(Paint.Style.FillAndStroke); * * // Center the character in the rectangle * Android.Graphics.Rect bounds = new Android.Graphics.Rect(); * letterPaint.GetTextBounds(mPreviousCharacter.ToString(), 0, 1, bounds); * * int textLeft = rect.Left + (int)((rect.Width - bounds.Width()) / 2.0); * int textBottom = rect.Bottom - (int)((rect.Height - bounds.Height()) / 2.0); * * canvas.DrawText(mPreviousCharacter.ToString(), textLeft, textBottom, letterPaint); * }*/ }
void DrawHands(Canvas canvas, Rect bounds) { var width = bounds.Width(); var height = bounds.Height(); var centerX = width / 2.0f; var centerY = height / 2.0f; calendar.TimeInMillis = Java.Lang.JavaSystem.CurrentTimeMillis(); var hour = calendar.Get(CalendarField.Hour); var minute = calendar.Get(CalendarField.Minute); var second = calendar.Get(CalendarField.Second); var secRot = second / 30f * (float)Math.PI; var minutes = minute; var minRot = minutes / 30f * (float)Math.PI; var hrRot = ((hour + (minutes / 60f)) / 6f) * (float)Math.PI; var secLength = centerX - 20; var minLength = centerX - 40; var hrLength = centerX - 80; if (!IsInAmbientMode) { var secX = (float)Math.Sin(secRot) * secLength; var secY = (float)-Math.Cos(secRot) * secLength; canvas.DrawLine(centerX, centerY, centerX + secX, centerY + secY, secondPaint); } var minX = (float)Math.Sin(minRot) * minLength; var minY = (float)-Math.Cos(minRot) * minLength; canvas.DrawLine(centerX, centerY, centerX + minX, centerY + minY, minutePaint); var hrX = (float)Math.Sin(hrRot) * hrLength; var hrY = (float)-Math.Cos(hrRot) * hrLength; canvas.DrawLine(centerX, centerY, centerX + hrX, centerY + hrY, hourPaint); }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); canvas.DrawColor(Color.White); this.rootCanvas.SetTarget(canvas); using (var bounds = new Rect()) { canvas.GetClipBounds(bounds); rootCanvas.DrawRectangle(new RectF(bounds.Left, bounds.Top, bounds.Width(), bounds.Height()), Color.Red, Color.Transparent, 0); } }
public void Draw(Canvas c, Rect bounds) { RectF arcBounds = mTempBounds; arcBounds.Set(bounds); arcBounds.Inset(mStrokeInset, mStrokeInset); float startAngle = (mStartTrim + mRotation) * 360; float endAngle = (mEndTrim + mRotation) * 360; float sweepAngle = endAngle - startAngle; mPaint.Color = mColors[mColorIndex]; c.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint); DrawTriangle(c, startAngle, sweepAngle, bounds); if (Alpha < 255) { mCirclePaint.Color = BackgrounColor; mCirclePaint.Alpha = 255 - Alpha; c.DrawCircle(bounds.ExactCenterX(), bounds.ExactCenterY(), bounds.Width() / 2, mCirclePaint); } }
public BasicRectangle MeasureText(string text, BasicRectangle rectangle, string fontFace, float fontSize) { var paint = new Paint { AntiAlias = true, TextSize = fontSize * Density }; var rectText = new Rect(); paint.GetTextBounds(text, 0, text.Length, rectText); return new BasicRectangle(rectText.Left, rectText.Top, rectText.Width(), rectText.Height()); }
public Size MeasureText(string text, string fontFamily = null, double fontSize = 10, double fontWeight = 500) { if (string.IsNullOrEmpty(text)) { return Size.Empty; } using (var paint = new Paint()) { paint.AntiAlias = true; paint.TextSize = (float)fontSize; var bounds = new Rect(); paint.GetTextBounds(text, 0, text.Length, bounds); // var width = paint.MeasureText(text); return new Size(bounds.Width(), bounds.Height()); } }
public override void OnDraw(Canvas canvas, Rect bounds) { if (Log.IsLoggable (Tag, LogPriority.Debug)) { Log.Debug (Tag, "onDraw"); } long now = Java.Lang.JavaSystem.CurrentTimeMillis (); time.Set (now); int milliseconds = (int)(now % 1000); int width = bounds.Width (); int height = bounds.Height (); // Draw the background, scaled to fit. if (backgroundScaledBitmap == null || backgroundScaledBitmap.Width != width || backgroundScaledBitmap.Height != height) { backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap, width, height, true /* filter */); } canvas.DrawColor (Color.Black); canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null); float centerX = width / 2.0f; float centerY = height / 2.0f; // Draw the ticks. float innerTickRadius = centerX - 10; float outerTickRadius = centerX; for (int tickIndex = 0; tickIndex < 12; tickIndex++) { float tickRot = (float)(tickIndex * Math.PI * 2 / 12); float innerX = (float)Math.Sin (tickRot) * innerTickRadius; float innerY = (float)-Math.Cos (tickRot) * innerTickRadius; float outerX = (float)Math.Sin (tickRot) * outerTickRadius; float outerY = (float)-Math.Cos (tickRot) * outerTickRadius; canvas.DrawLine (centerX + innerX, centerY + innerY, centerX + outerX, centerY + outerY, tickPaint); } float seconds = time.Second + milliseconds / 1000f; float secRot = seconds / 30f * (float)Math.PI; int minutes = time.Minute; float minRot = minutes / 30f * (float)Math.PI; float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI; float secLength = centerX - 20; float minLength = centerX - 40; float hrLength = centerX - 80; if (!IsInAmbientMode) { float secX = (float)Math.Sin (secRot) * secLength; float secY = (float)-Math.Cos (secRot) * secLength; canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint); } float minX = (float)Math.Sin (minRot) * minLength; float minY = (float)-Math.Cos (minRot) * minLength; canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint); float hrX = (float)Math.Sin (hrRot) * hrLength; float hrY = (float)-Math.Cos (hrRot) * hrLength; canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint); if (IsVisible && !IsInAmbientMode) { Invalidate (); } }
public Rect GetFramingRect() { if (framingRect == null) { if (camera == null) return null; } if (screenResolution == Size.Empty) return null; int width = screenResolution.Width * 15 / 16; if (width < MIN_FRAME_WIDTH) width = MIN_FRAME_WIDTH; else if (width > MAX_FRAME_WIDTH) width = MAX_FRAME_WIDTH; int height = screenResolution.Height * 4/ 10; if (height < MIN_FRAME_HEIGHT) height = MIN_FRAME_HEIGHT; else if (height > MAX_FRAME_HEIGHT) height = MAX_FRAME_HEIGHT; int leftOffset = (screenResolution.Width - width) / 2; int topOffset = (screenResolution.Height - height) / 2; framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); Android.Util.Log.Debug("ZXING", "Framing Rect: X=" + framingRect.Left + " Y=" + framingRect.Top + " W=" + framingRect.Width() + " H=" + framingRect.Height()); return framingRect; }
/// <summary> /// Sets the scan crop to limit decoded area. /// </summary> /// <para> /// ZBar have somewhat changed the coordinate system for defining images. See 'http://stackoverflow.com/a/21258169' for more information /// </para> /// <para> /// The x-axis is defined to strecht the longest side of the image and the y-axis the shortest. /// An image viewed in portrait mode looks like /// (y,0)----------------(0,0) /// | | /// | | /// | | W /// | | i /// | | d /// | | t /// | | h /// | | /// | | /// | | /// |________________| /// (y,x) <- Height -> (x,0) /// </para> /// <param name="rect">Rect defining the scan crop area</param> public void SetCrop(Rect rect) { SetCrop(rect.Left, rect.Top, rect.Height(), rect.Width()); }