Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for MAUI: Convert FileImageSource to byte[]

$
0
0

You can try to use the following code:

public static async Task<byte[]> ImageSourceToByteArrayAsync(){   var assem = Assembly.GetExecutingAssembly();   using var stream = assem.GetManifestResourceStream("ProjectName.Resources.Images.test.png");   byte[] bytesAvailable = new byte[stream.Length];   stream.Read(bytesAvailable, 0, bytesAvailable.Length);   return bytesAvailable;}

The test.png is in the \Resources\Images and its build action is EmbeddedResource.


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>