Page 1 of 1

Embedding images into a script

Posted: November 27th, 2009, 3:51 am
by jaist
Hi all!
I'd like to embed images in my .jsxbin, but i'm at loss when i think about extracting bytes from my file in javascript.
I saw nab's implementation with hexes, creating temp images and reading from there, but while effective it's quite ankward.
Do any of you know a simpler approach? I'd like to deploy only one file instead of three. Thanks!
Max

Re: Embedding images into a script

Posted: November 27th, 2009, 12:23 pm
by nab
Not sure it is simpler, but here is another road I've explored.

Assuming we are dealing with little iconic image, typically of size less 50x50 px, you can sample every image pixel and create for each pixel a 1px group (with backgroundColor set to the current pixel color).

In this demo, the icon image is the first selected layer, and layer sampling is done using sampleImage() expression.

LayerToUIImage.jsx.zip


Image