Skip to main content

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

So, I'm trying to add import options to the image importer/exporter contraption I'm building. So far, this is the interface and everything seems to be working fine. "Extra Options" just makes everything disappear, keeping only itself and the Import/Export buttons.


Only one of the checkbox buttons can be selected at a time (I'm using a basic "if" to check the value of each one and unmark the other 2 if is true).

Here's how the images look when imported in the order of the checkboxes.




So, erm, I think the issue is clear. The Gray Import isn't importing in grays, but rather in a psychedelic way.  Funny enough, the Dither Import relies on the Gray Import to use transformation, otherwise it just completely breaks too. But even so, the Dither result is noisier than just dragging and dropping an image into Decker.

It's worth noting the image is a jpeg, so I'm not sure why it's getting animated with the Gray Import.

Here's the code in the Import button:

on click do
    if colorbutton.value=1
        i:read["image"]
        card.image.paste[i 0,0,card.size]
    end
    if graybutton.value=1
        i:read["image" "gray"]
        card.image.paste[i 0,0,card.size]
    end
    
    if ditherbutton.value=1
        i:read["image" "gray"]
        i.transform["dither"]
        card.image.paste[i 0,0,card.size]
    end
end

I tested it with a canvas, and also did some testing in the Listener, but I can't figure out what's going on, if there should be some other sort of conversion happening before, or something like that.

This is working as designed. 256-gray images are not directly displayable within Decker, since Decker's color palette does not contain 256 colors and patterns; only 48:

 

A grayscale image must be converted into a proper paletted image before it can be displayed; otherwise the grayscale values are effectively randomly mapped to entries in the above table, and any higher indices appear as white. The image.transform["dither"] function is one way to produce a 1-bit dithered image from a 256-gray image, using Bill Atkinson's algorithm. Rescaling a dithered image will considerably reduce its quality. The correct order of operations to prepare a dithered image therefore must be:

  1. obtain or otherwise create a 256-gray image.
  2. perform any desired palette adjustments to the 256-gray image, like adjusting white/black points or contrast.
  3. scale and crop the 256-gray image to the desired final size.
  4. dither the 256-gray image, resulting in an image consisting exclusively of patterns 0/1.
(4 edits)

I was talking about this on cohost and millie also told me about Decker not being able to display the 256 grays which... makes complete sense tbh, as you yourself explained the palette limitation (which I actually know but didn't connect the dots, so I'm a bit embarrassed). Funny enough people liked the result, so I think I'll rename the option and leave it there for them to use and give life to fever dreams. 

And the order for the dithered image makes sense now, I'll rewrite its import code and see if I can get it right then. Thanks a lot!

Edit: the dithering improved a lot now!