Image don't show on Universal Windows Plataform

Hi!
I'm creating an app to Universal Windows Plataform and Android
I've tried to display an image on Android Emulator, Window Phone emulator and Local Machine
But, only on Android the image is displayed
What can be the problem?
Thanks very much

Download Manager:

namespace App2.manager
{
    public class ImagemDownloader
    {
        public static async Task<Image> downloadAsync(string uri, double largura, double altura)
        {
            HttpClient cliente = Cliente.GetCliente();
            System.IO.Stream s = await cliente.GetStreamAsync(uri);
            Image imagem;
            if (largura > 1 || altura > 1)
            {
                imagem = new Image()
                {
                    Source = ImageSource.FromStream(() => s),
                    WidthRequest = largura,
                    HeightRequest = altura,
                    MinimumHeightRequest = altura,
                    MinimumWidthRequest = largura
                };
            }
            else
            {
                imagem = new Image()
                {
                    Source = ImageSource.FromStream(() => s),
                };
            }
            return imagem;
        }
    }
}

Page XAML:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Digas.pages.UsuarioPerfilPage"
             xmlns:i="clr-namespace:Digas.manager"
             xmlns:j="clr-namespace:Digas.views"
             >

    <ContentPage.Content>
        <StackLayout>
            <Image HorizontalOptions="Center" x:Name="fotoperfil"></Image>

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Page c#

namespace Digas.pages
{
    public partial class UsuarioPerfilPage : ContentPage
    {
        private Usuario usuario = null;

        public UsuarioPerfilPage()
        {
            InitializeComponent();

            atualizarTudo();                
        }

        private async Task atualizarTudo()
        {
            try
            {
                usuario = await UsuarioManager.Get("3");
                BindingContext = usuario;
                atualizaimagemperfil();


            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(" Erro! ---------------------------------------------------------> " + ex.ToString());
            }
        }
        private async void atualizaimagemperfil() {
            fotoperfil.Source = await ImagemDownloader.downloadAsync(usuario.FotoUrl);
        }
    }
}

Answers

  • Someone?

  • PrasadCPPrasadCP USMember ✭✭

    Actually Where you are downloading your the image? I mean the location. Are you downloading native or not?

  • RodrigoBertottiRodrigoBertotti USMember
    edited April 2017

    @PrasadCP said:
    Actually Where you are downloading your the image? I mean the location. Are you downloading native or not?

    Hi, it's not native
    I'm using: System.Net.Http;

Sign In or Register to comment.