Closed smvilar closed 8 years ago
@underscorediscovery have you seen this issue? I wanna know if I'm doing something wrong here.
I have seen this but I've been busy in the backend, but I had a quick look so long.
Here's what I mean, this is a working png file (default font):
And here is your data:
What you see here is actually a �
, a replacement character.
When encoded as UTF-8, this character (0xFFFD
) becomes �
(0xEF 0xBF 0xBD
).
When I see that - I know that somewhere, the data has been converted to UTF-8 encoding, when it shouldn't be. This means that it will mess with the raw PNG data, making the image data invalid.
In simpler words: The error comes from the conversions, before getting to the image_from_bytes
call.
Internally snow uses js.html.XMLHttpRequest()
directly,
request.overrideMimeType('text/plain; charset=x-user-defined');
request.responseType = js.html.XMLHttpRequestResponseType.ARRAYBUFFER;
new Uint8Array(request.response)
because it's already a typed arrayThe reason I did it this way internally was because of similar encoding problems, where it must remain binary data in order to be used correctly.
Hope that helps so long.
Thanks! I updated the example to use js.html.XMLHttpRequest
directly with the parameters you set and it worked.
I should warn @bmfs to update his gist
I should warn @bmfs to update his gist
@smvilar Good idea. If you cannot reach him, you can fork his gist and correct it and then ping me and I'll point the link to the corrected gist instead.
just updated the gist to use Luxe.snow.io.data_load(url).
Thanks for the warning
:+1:
I'm trying to use this sample from
awesome-snowkit
to load an image from the url and display it in a luxe texture.I made this repo with the actual test: https://github.com/smvilar/luxe-image-from-url
The console displays this error when calling
Luxe.snow.assets.image_from_bytes