Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

Yes. Just as it is possible to export images with the "write[]" function, you can import images with "read[]", which takes a few arguments to specify what type of file you wish to open, and how you wish to interpret it. The documentation for this is near the bottom of  the Built-In Functions section of the manual.

As an example, let's say we have a card with a canvas named "c" and a button with a script like so:


The default behavior for importing an image is to posterize it to Decker's 16-color palette. If we want a dithered image, we need to read it in grayscale and resize it (in this case using another image as a scratchpad) before we perform the dithering for best quality:


In these examples I'm resizing the image to fit the dimensions of the canvas, which slightly vertically squishes the image of Pippi the hen. Depending on your specific needs you might also choose to resize the image and/or the canvas proportionally, letterbox or crop the image.

It's also perhaps worth noting that Decker is capable of decoding the individual frames of animated GIF images, so it's possible to make a variety of animation player/viewer applications. The Bazaar has some examples. Likewise, it's also possible to export animated GIFs with "write[]".

Does that give you a useful starting point?

Thank you!

The posterised image works, but I can't get the dithered version to work, and I'm afraid I'm also saving the background behind the canvas for some reason....

See https://wwwdot.org/dither-save-bug.html

Looks like you have a typo of ':' instead of '.' in your grayscale import script. Try this:

on click do
 # make 1-bit dithered image
 i:read["image" "gray"]
 r:image[c.size]
 r.paste[i 0,0,r.size]
 r.transform["dither"]
 c.paste[r]
end

Sometimes it's helpful to try things step-by-step in the Listener when they don't seem to work properly:

As for image export, you're only copying from the card's background image, which does not include the contents of any canvases stacked on top:

on click do
 write[card.image.copy[c.pos c.size]]
end

If you want to export the image, you need to "copy[]" from the canvas:

on click do
 write[c.copy[]]
end

And as in the examples for The Ornamented Ovum, you may want to map pattern 0 (transparent) to pattern 32 (opaque white) before exporting:

on click do
 write[c.copy[].map[0 dict 32]]
end

(+1)

Ah you're so patient -- thank you!

Here it is now: https://wwwdot.org/1bit-photobooth.html

Mastadon and Facebook appear to be happy with the resulting gif image output, but Twitter complains that the file is invalid.