rgbds icon indicating copy to clipboard operation
rgbds copied to clipboard

Add `rgbgfx -c png` to specify palette specs as visible images

Open Rangi42 opened this issue 2 years ago • 12 comments

Each color would be a single pixel, read top to bottom, left to right. (So for two palettes a user might supply a 1x8 png, or 8x1, or 4x2, or even 2x4.) The png's encoding wouldn't matter, only the individual pixels' colors.

Rangi42 avatar Jan 03 '23 17:01 Rangi42

Why top to bottom? Left to right first seems more intuitive

evie-calico avatar Jan 03 '23 18:01 evie-calico

I mean the standard row-by-row order of English reading, electron gun scanning, etc.

Rangi42 avatar Jan 03 '23 18:01 Rangi42

If we're going to do this, it might be worthwhile to also allow something like -c png42 to indicate that each color is represented by a 42×42 box instead of 1×1 (for any value of 42, of course). The reason for this is that many visualization tools will only reduce large images, but not expand small ones (or what's worse, use some sort of bilinear filtering when expanding small ones, creating lots of blur), which makes small images very hard to visualize outside of editing tools.

aaaaaa123456789 avatar Jan 03 '23 19:01 aaaaaa123456789

That sounds useful too, although it could be a follow-up issue once this one is resolved.

Rangi42 avatar Jan 03 '23 19:01 Rangi42

On second thought, i still think it would be worth being able to embed the palette in the first or last row of the image. For images which have unique palettes, I don’t see the point in creating a separate file with the palette definitions only for it to be used once. It only makes it more cumbersome to modify the palette, needing to do so in two files rather than one.

evie-calico avatar Jan 07 '23 01:01 evie-calico

I would make -c png:image.png determine the box size automatically (inferring it from the amount of identical consecutive pixels on the first row), and -c png,42:image.png/-c png@42:image.png (not : to avoid parsing ambiguities) to enforce a specific size.

For images which have unique palettes, I don’t see the point in creating a separate file with the palette definitions only for it to be used once. It only makes it more cumbersome to modify the palette, needing to do so in two files rather than one.

It's for consistency: if you are using -c png generically, it's okay; if you aren't using it for specific images, you might as well use at-files.

ISSOtm avatar Jan 07 '23 18:01 ISSOtm

For images which have unique palettes, I don’t see the point in creating a separate file with the palette definitions only for it to be used once. It only makes it more cumbersome to modify the palette, needing to do so in two files rather than one.

Also you don't have to create a separate file; you should be able to pass rgbgfx -c input.png -o output.2bpp input.png.

Rangi42 avatar Jan 07 '23 23:01 Rangi42

But then it’ll read the image as a palette… that doesn’t make sense. if you make the first line of the image the palette you want to use, that line will show up in the output

evie-calico avatar Jan 07 '23 23:01 evie-calico

Ah, you're right, I was thinking in terms of an indexed palette, but that's what embedded is already for.

Rangi42 avatar Jan 07 '23 23:01 Rangi42

I think what you're describing is some imaginary mode -c from:foo.png where the palette is taking from another file's indexed palette.

aaaaaa123456789 avatar Jan 07 '23 23:01 aaaaaa123456789

At the very least, this should be compatible with the PNGs generated by contrib/view_palettes.sh.

ISSOtm avatar Aug 14 '24 15:08 ISSOtm