forms-gtk-progress
forms-gtk-progress copied to clipboard
ImageSource.FromStream() produces "Unrecognized image file format" from GDK
Trying to update an Image through a stream source with various permutations of code such as:
SourceStream = new MemoryStream(buffer);
Source = ImageSource.FromStream(() => SourceStream);
Where buffer is a simple byte[] containing pixel values.
This isn't working, but I get some curious errors in the output window:
[Image loading] Image load failed: GLib.GException: Unrecognized image file format at Gdk.PixbufLoader.Write(Byte[] buf, UInt64 count) at Gdk.PixbufLoader.LoadFromStream(Stream input, Byte[] streamingBuffer) at Gdk.PixbufLoader.InitFromStream(Stream stream, Byte[] buffer) at Gdk.PixbufLoader..ctor(Stream stream, Byte[] streamingBuffer) at Gdk.Pixbuf..ctor(Stream stream) at Xamarin.Forms.Platform.GTK.Renderers.StreamImagesourceHandler.<LoadImageAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Xamarin.Forms.Platform.GTK.Renderers.ImageRenderer.<SetImage>d__5.MoveNext()
As near as I can tell, GDK expects streams to be actual valid image files, such as .png or .jpeg, while Xamarin's API is supposed to just pass around raw buffers wrapped in streams. This is either a Xamarin.Forms GTK bug, or else the documentation badly needs revision. Actually, the documentation needs revision anyway since the only information I can find about what you're supposed to pass in the source stream comes from various forum threads and mailing lists.
Oh, I will prepare some tests and I will check what happens. Thank you!