I'm having trouble setting an Image Source to a byte array of bitmap data. I've done this before using a jpg. Now I have an array of RGBA data and I keep getting an error:
ImageLoaderSourceHandler: Image data was invalid: Xamarin.Forms.StreamImageSource
Here's the sample code I'm using. I'm just trying to setup a 64x64 random image for now:
[code]
byte[] data = new byte[64 * 64 * 4];
Random r = new Random();
int o = 0;
for (int i = 0; i < 64 * 64; i++)
{
data[o++] = (byte)r.Next(255);
data[o++] = (byte)r.Next(255);
data[o++] = (byte)r.Next(255);
data[o++] = (byte)r.Next(255);
}
test.Source = ImageSource.FromStream(() => new MemoryStream(data));
[/code]
Any ideas what I'm doing wrong? Can an Image in Xamarin.Forms take a byte array of RGBA or RGB data?
Thanks!
Jeff.