[Partially solved] X windows colormap - True Color 16 bit

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

[Partially solved] X windows colormap - True Color 16 bit

Post by markmarques »

in the "Usage web docs" I have found this :
---------------------------------------------------
TrueColor 16bit Colormap
A similar uniform colormap to the '332 colormap' above is used by X windows in a rarely used 16 bit visual class. In this case, 16 bits are used for the color index which is divided into 5 bits for red, 5 for green, and 6 for blue.
------------------------------------------------------------------------------

But I can not know how to calculate it ... :(
I have tried something like this :
convert -size 16x16 xc: -channel R -fx "(i%32)/31"
-channel G -fx "(j%32)/31"
-channel B -fx "((i>>6&1)|(j>>6&6))/7" -scale 500% colormap_X.png

But I supposed it not right ....

My real problem is that I have an old X windows legacy application that imports GIF files but no matter what I try I simply do not have the correct color ...
Although I have something read in it gives me the wrong palette ...

Nonetheless all the other different image viewers gives the correct colors ....
My point is that my Xwindows app simply remaps the GIF into their own internal palette (?!?!?! ) :(

I tried the "netscape:" option and built the 332 palette ...

But I am getting out of ideas ... :(
Last edited by markmarques on 2011-08-16T08:01:37-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: X windows colormap - true Color 16 bit

Post by anthony »

See IM examples, Quantization and Dithering, 332 colormap, and the next section 556 colormap
http://www.imagemagick.org/Usage/quantize/#332_colormap

You can generate this using a -ordered-dither with a threshold and the number of color levels (actual number not number of bits) needed. See Ordered Dither using Uniform Color Levels
http://www.imagemagick.org/Usage/quantize/#od_posterize

Specifically for a 556 colormap use... -ordered-dither threshold,32,32,64

I have updated the section near the first link with this info (which was not available when I first wrote it).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
markmarques
Posts: 88
Joined: 2010-06-29T14:36:09-07:00
Authentication code: 8675308

Re: [Partially solved] X windows colormap - True Color 16 bi

Post by markmarques »

First:thanks for the adjustment in the "Usage Docs"...

I have tried the "-ordered-dither threshold, 32,32,64" and it worked
but I realize that the problem is my legacy X windows application...

I only get the "colors" that I need if I have request "-colors 7" less than 7 colors ....

Nonetheless I noticed that I do get the "correct colors" only if I occupy the first 16 colors inside the GIF palette ...

Is there any way for editing the order of the colors inside the palette ?

Normally I know that the default is to order the palette from dark to light
and most of the other palette editing software accepts changes from like swapping from color X to color Y changing the colors in the original image.

My idea would be ordering the palette without changing the original image ...
( bizarre I know ...)

Just to say thanks again for the fast answer ...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [Partially solved] X windows colormap - True Color 16 bi

Post by anthony »

At this time there does not appear to be any way of actually ordering the palette that is produced.

In any case a GIF colortable is only 256 colors maximum, so can not actually hold all 16bit colors possible.

It looks to me like you may need to get some extremely fine control of the pallet in GIF.

Your best bet for this is either looking at say a GIF image generator library (say in perl or some other language), or simply grab the source code of the GIF codec in ImageMagick, and modify it to adjust the sort order of the colors.

I have no idea how simple or complex that is.


One aspect that is on the IMv7 to-do list is a method of separately storing the original (or input) palette with the image so that images can be mapped back to using the specific color index values of the original image. It isn't however a high priority. It is however something worth discussing no the developers forum, but unless we get some interested programmer it may never happen.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply