xamarin / SignaturePad

MIT License
245 stars 150 forks source link

Black Image when I get Stream #147

Closed easoftwaresanderson closed 6 years ago

easoftwaresanderson commented 6 years ago

Description

When I use the function GetImageStreamAsync to get the Stream and return this stream to a Image

Code

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:forms="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms" xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" prism:ViewModelLocator.AutowireViewModel="True" x:Class="AppHRSClean.Views.AssinaturaPage" Title="Assinatura do Responsável">

using AppHRSClean.Basicos; using AppHRSClean.Infrastructure; using AppHRSClean.Model; using AppHRSClean.Services; using AppHRSClean.ViewModels; using SignaturePad.Forms; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace AppHRSClean.Views { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class AssinaturaPage : ContentPage { public AssinaturaPage() { InitializeComponent (); } public async void SalvarAssinatura(object sender, EventArgs eventArgs) { Task Taskstream = Pad.GetImageStreamAsync(SignatureImageFormat.Jpeg); Stream stream = await Taskstream; imgAssinatura.Source = ImageSource.FromStream(() => { return stream; }); } } } using AppHRSClean.Basicos; using AppHRSClean.Infrastructure; using AppHRSClean.Model; using AppHRSClean.Services; using AppHRSClean.ViewModels; using SignaturePad.Forms; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace AppHRSClean.Views { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class AssinaturaPage : ContentPage { public AssinaturaPage() { InitializeComponent (); } public async void SalvarAssinatura(object sender, EventArgs eventArgs) { Stream stream = await Pad.GetImageStreamAsync(SignatureImageFormat.Jpeg); imgAssinatura.Source = ImageSource.FromStream(() => { return stream; }); } } } ### Expected Behavior ### Actual Behavior ### Basic Information - Version with issue: - Last known good version: - IDE: - Platform Target Frameworks: - Android: - iOS: - UWP: - Xamarin.Forms: - Target Devices: - ### Screenshots ![image](https://user-images.githubusercontent.com/40809443/44950952-05de0d80-ae2d-11e8-8a3b-e5064976bf01.png) ### Reproduction Link
easoftwaresanderson commented 6 years ago

I found the problem. If you don't specified the parameters strokeColor and fillColor this issues happen.

Follow the correct code .:

        var image = await Pad.GetImageStreamAsync(
                        SignatureImageFormat.Jpeg,
                        strokeColor: Color.Black,fillColor: Color.White);

        imgAssinatura.Source = ImageSource.FromStream(() =>
        {
            return image;
        });