public void UploadSketchIdea(SketchIdea sketchIdea, byte[] imageBytes) { var stream = new MemoryStream(imageBytes); var fileId = _fileDalService.UploadFile(stream); stream.Dispose(); sketchIdea.PictureId = fileId; sketchIdea.ImageSource = ImageSource.FromFile(CacheImageBytesToFile(imageBytes, sketchIdea.PictureId)); }
private void Save_Clicked(object sender, EventArgs e) { var info = new SKImageInfo((int)canvasView.CanvasSize.Width, (int)canvasView.CanvasSize.Height); var surface = SKSurface.Create(info); var canvas = surface.Canvas; canvas.Clear(); foreach (FingerPaintPolyline polyline in completedPolylines) { paint.Color = polyline.StrokeColor.ToSKColor(); paint.StrokeWidth = polyline.StrokeWidth; canvas.DrawPath(polyline.Path, paint); } foreach (FingerPaintPolyline polyline in inProgressPolylines.Values) { paint.Color = polyline.StrokeColor.ToSKColor(); paint.StrokeWidth = polyline.StrokeWidth; canvas.DrawPath(polyline.Path, paint); } canvas.Flush(); var snap = surface.Snapshot(); SketchIdea sketchIdea = new SketchIdea(); byte[] bytes; using (var data = snap.Encode(SKEncodedImageFormat.Png, 80)) { sketchIdea.ImageStream = data.AsStream(); bytes = data.ToArray(); } _brainstormingService.UploadSketchIdea(sketchIdea, bytes); _brainstormingService.CommitIdea(sketchIdea); DisplayAlert(AppResources.SketchSavedTitle, AppResources.SketchSavedMessage, AppResources.Ok); }