Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Read image

A topic by atejada created Nov 24, 2022 Views: 222 Replies: 2
Viewing posts 1 to 3

When importing an image on Decker, it is pixelated and grayscaled. Then we get something like "%%IMG2AgABVgD\/AP8A\/wD\/AP8A\/wD\/AP8A\/wD\/A..." is there a way to use lilt or lil to read an image and get that string back? I guess I could grab the C++ or JS code and replicated on Ruby or Python...but just wanted to know if this something already built in...

Thanks in advance...

Developer(+1)

Both Decker and Lilt have a read[] function which can be used to read image files. The signatures are slightly different, since Decker prompts the user to open a file interactively while Lilt expects an explicit file path. When you load an image file, you will get an image interface, which, among other things, has a ".encoded" attribute which will give you the same sort of encoded image-string you get when you copy an image manually using Decker's drawing tools.

Let's say we're working in the Decker listener and we'd simply like to open an image, dither it, and then print the encoded string:

read["image" "gray"].transform["dither"].encoded

Or the same thing from Lilt:

read["path/to/image.gif" "gray"].transform["dither"].encoded

Web-decker supports a wide range of image formats- anything your browser can decode. Native decker supports GIF, BMP, PNG, and JPEG. Lilt supports only GIF.

(+1)

Thanks! I was trying using read[] but wasn't aware of the .encoded  馃槃 I wish lilt could support png as well...but .gif should be good enough for me...thanks again! When I'm finished with my project I will surely post it here....Decker is so good! I used to use Hypercard on the Macintosh Plus eons ago 馃槄