Binary to costume

I get a file form the url block that's an image (e.g. png, jpeg, ect) but it returns a string, how to I turn this into a costume?

<blocks app="Snap! 6," version="1"><block-definition s="costume from url %&apos;url&apos;" type="reporter" category="looks"><comment x="0" y="0" w="96.36363636363625" collapsed="false">Credit to @programmer_user and @jens</comment><header></header><code></code><translations></translations><inputs><input type="%s">Costumes/alonzo.png<options>function () {&#xD;var obj = {};&#xD;world.children[0].getMediaList(&apos;Costumes&apos;).forEach(image =&gt; {&#xD;obj[] = &apos;Costumes/&apos; + image.fileName;&#xD;})&#xD;return obj;&#xD;}</options></input></inputs><script><custom-block s="let %upvar be %s"><l>costume</l><block s="evaluate"><block s="reportJSFunction"><list><l>url</l></list><l>var img = new Image(),&#xD;    cst = null,&#xD;    canvas;&#xD;img.onload = function() {&#xD;    canvas = document.createElement(&apos;canvas&apos;);&#xD;    canvas.width = img.width;&#xD;    canvas.height = img.height;&#xD;    canvas.getContext(&apos;2d&apos;).drawImage(img, 0, 0);&#xD;    cst = new Costume(canvas);&#xD;}&#xD;img.crossOrigin = &apos;anonymous&apos;;&#xD;img.src = url;&#xD;return () =&gt; cst;</l></block><list><block var="url"/></list></block></custom-block><block s="doWaitUntil"><block s="evaluate"><block var="costume"/><list></list></block></block><block s="doReport"><block s="evaluate"><block var="costume"/><list></list></block></block></script></block-definition><block-definition s="let %&apos;var&apos; be %&apos;val&apos;" type="command" category="other"><comment x="0" y="0" w="183.33333333333334" collapsed="false">LET (FOO) BE (5)&#xD;is equivalent to&#xD;SCRIPT VARIABLES (FOO)&#xD;SET (FOO) TO (5)</comment><header></header><code></code><translations>pt:cria a variável de guião _ com valor _&#xD;</translations><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="val"/></block></script></block-definition></blocks>

Does it work for whole url? e.g.


Doesn't work.

did you make sure that the url was to the image?

I found the solution myself.

I gave you the solution already.

Yes but it didn't work in netsblox.

Why are you asking a netsblox question in the Snap! Forums then?

It's not necessarily related to NetsBlox.

You might need it in Snap! too.

But you can ask it on the netsblox forum.

Why are you so against posting on the Netsblox forum anyway?

  1. You might want to use it on Snap! too.
  2. It takes forever to get a reply on the NetsBlox forums.

Plus I do bug reports and stuff like that on NetsBlox.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.