01-19-2021, 09:25 PM
(01-19-2021, 01:10 PM)Winston Wrote: There seems to be a miscommunication.
I'm trying to program a picture file to have 2-channel color, not have one with 3-color only have 2 colors.
For instance, it could be colored #YYBB, #RRCC, or #MMGG, instead of #RRGGBB.
We hear this. But there is no image format that supports this, at least none that is natively supported in GIMP. So out of the box you have to work with a 3-channel format where one channel remains unused. This isn't as wasteful as it looks since the compression algorithms can be expected to take this uniformity in account. Or you know how to program and write your own file load/save plugin (all file formats in Gimp except XCF are implemented as plugins...)
(01-19-2021, 01:10 PM)Winston Wrote: Black-&-White would still be possible, writing as #0000 for black, #8080 for gray, and #FFFF for white. #FF00 would be one color, #00FF would be the inverted color.Most image formats (except very basic BMP and TGA) are compressed, so you won't see the pixel values in a hex editor.
Using a different program, I tried looking for "03" hexadecimally in the beginning of picture files representing three colors, and changing it to "02", that didn't work.
Where is this "3" stored in an image file? Is it "2" because it starts from 0; 0=1, 1=2, 2=3? If that is the case, would changing it to 1 (=2) work?
A possible solution for you is to color-index the image using a color palette that only contains the colors you want, that would give you 16 levels of luminosity and 16 levels across the color range (and you would use one byte per pixel when encoding the image). Or combos are possible as long as you have 256 colors total. And you can change the image by just changing colors in the color map. The GIF format is based in color-indexing (in fact, GIMP's color-indexed image mode is meant to edif GIFs), and is also a supported variant of PNG.