Get image from "Resources" folder from android

Asked

Viewed 61 times

0

Good morning,

I have an android app made in C# via Xamarin. In this application, there is a report made in HTML that is displayed in a Webview. This report needs to display an image (PNG) that is stored in my project’s Resources folder. To do this, my idea is to get the image from the Resources folder and copy it to the directory that is my HTML file and in the HTML source I would access this image. But I could not access the Resources folder.

Completion: how to copy a file from the Resources folder to another directory?

From now on, thank you.

  • Include your code, show how you are trying to do it and indicate the error you find

  • @Leandroangelo already found the resolution and put as an answer here. Anyway, thank you.

1 answer

0


Android.Graphics.Bitmap bitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.imagem_origem);
string path = diretorioDestino + "imagem_destino.png";
using (var stream = System.IO.File.OpenWrite(path))
{
     bitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 100, stream);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.