/// <summary> /// Display result in TextView /// </summary> private void DisplaySuccess(MLImageSegmentation imageSegmentationResult) { if (this.mBitmapTarget == null) { this.DisplayFailure(); return; } // Draw the portrait with a transparent background. Bitmap bitmapFore = imageSegmentationResult.Foreground; if (bitmapFore != null) { this.mImageResultView.SetImageBitmap(bitmapFore); } else { this.DisplayFailure(); } }
public MLSegmentGraphic(LensEnginePreview preview, GraphicOverlay overlay, MLImageSegmentation segmentation, Boolean isFront) : base(overlay) { this.bitmapForeground = segmentation.Foreground; this.isFront = isFront; int width = bitmapForeground.Width; int height = bitmapForeground.Height; int div = overlay.Width - preview.Width; int left = overlay.Width - width + div / 2; // Set the image display area. // Partial display. mDestRect = new Rect(left, 0, overlay.Width - div / 2, height / 2); // All display. // mDestRect = new Rect(0, 0, overlay.Width, overlay.Height); this.resultPaint = new Paint(PaintFlags.AntiAlias); this.resultPaint.FilterBitmap = true; this.resultPaint.Dither = true; }