Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageSource.FromStream() produces "Unrecognized image file format" from GDK #6

Open
keldor314 opened this issue Nov 27, 2017 · 1 comment
Assignees

Comments

@keldor314
Copy link

keldor314 commented Nov 27, 2017

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.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.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.

@jsuarezruiz jsuarezruiz self-assigned this Nov 27, 2017
@jsuarezruiz
Copy link
Owner

Oh, I will prepare some tests and I will check what happens. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants