Board index » delphi » Mode $13 palette problems

Mode $13 palette problems

Hi all, Well, my problem is that I designed a program to load a 256 color
image file, and display it on screen. (happens to be grayscale) - So all the
palette entries should be like :
Index  Red Green Blue
1       1    1     1
2       2    2     2
.
.
.
n       n    n     n
To 255.
This is right isn't it?
Anyway, I got the image to display alright, except that all the colors
were not correct.  It seems that every value set up to 63 was alright,
but after that it would just increment from zero again, doing this four
times until it reached 255.  Incedentally, I got it to display what
looked close to correct by dividing the RGB values by four, but this left
me with 64 colors instead of 256.  I looked into using different
setpalette procedures, but they all had the same effect.  Obviously there
is something I am missing.
I would appreciate any suggestions, either by email or news (or both, if
thats what turns ya on :)
Thanks in advance, Dave LeBlanc, ac...@ccn.cs.dal.ca

--

 

Re:Mode $13 palette problems


Quote
In article <4pqev6$...@apollo.isisnet.com> ac...@ccn.cs.dal.ca (Dave LeBlanc) writes:
>Hi all, Well, my problem is that I designed a program to load a 256 color
>image file, and display it on screen. (happens to be grayscale) - So all the
>palette entries should be like :
>Index  Red Green Blue
>1       1    1     1
>2       2    2     2
>.
>.
>.
>n       n    n     n
>To 255.
>This is right isn't it?

Yes and no. . . .

Quote
>Anyway, I got the image to display alright, except that all the colors
>were not correct.  It seems that every value set up to 63 was alright,
>but after that it would just increment from zero again, doing this four
>times until it reached 255.  Incedentally, I got it to display what
>looked close to correct by dividing the RGB values by four, but this left
>me with 64 colors instead of 256.  I looked into using different
>setpalette procedures, but they all had the same effect.  Obviously there
>is something I am missing.

Each DAC channel is only 6 bits wide, not 8, so in 256 color mode, you can
only get 64 real grey tones (where R=G=B).  When you set a color that's
greater than 63, the register value is effectively n mod 64.  It has nothing
to do with your setpalette procedures, it's the hardware that's
responsible.  If you want 256 shades of pure grey, you need to use
truecolor (16.8M colors), where each color channel is 8 bits.

Quote
>I would appreciate any suggestions, either by email or news (or both, if
>thats what turns ya on :)
>Thanks in advance, Dave LeBlanc, ac...@ccn.cs.dal.ca
>--

--
Scott Earnest          | We now return you to our regularly scheduled |
siny...@{*word*104}space.org | chaos and mayhem. . . .                      |

Re:Mode $13 palette problems


Quote
Dave LeBlanc wrote:

> ....
> Anyway, I got the image to display alright, except that all the colors
> were not correct.  It seems that every value set up to 63 was alright,
> but after that it would just increment from zero again, doing this four
> times until it reached 255.
> ....

The values _were_ being repeated every 64 colors.  The standard VGA DAC only allows 6
bits per primary color per DAC.  This allows for 18-bit color to be displayed.  Most
Super VGAs actually have a 24-bit DAC, but limit it's use to VGA standard 18-bits in
standard VGA modes.  In other words, using only greys (i.e. red = blue = green), you
only have 64 colors to work with.

Re:Mode $13 palette problems


Quote
In article <4pqev6$...@apollo.isisnet.com> ac...@ccn.cs.dal.ca (Dave LeBlanc) writes:

 ] Hi all, Well, my problem is that I designed a program to load a 256 color
 ] image file, and display it on screen. (happens to be grayscale) - So all the
 ] palette entries should be like :
 ] Index  Red Green Blue
 ] 1       1    1     1
 ] 2       2    2     2
 ] .
 ] .
 ] .
 ] n       n    n     n
 ] To 255.
 ] This is right isn't it?

No, any R, G, or B value has to be between 0 and 63, if you try to send
a number higher than 63 to the port, it will just perform a modulus (with 63)
(that's the effect of what happens anyway) so that all the values are between
0 and 63.  On a 256 color display, there are over 262k different colors that
can appear on the screen, but only 256 of them can appear at once.

 ] Anyway, I got the image to display alright, except that all the colors
 ] were not correct.  It seems that every value set up to 63 was alright,
 ] but after that it would just increment from zero again, doing this four
 ] times until it reached 255.  Incedentally, I got it to display what
 ] looked close to correct by dividing the RGB values by four, but this left
 ] me with 64 colors instead of 256.  I looked into using different

The way your image probably works is that it has RGB values ranging from 0
to 63, and then it has an intensity value ranging from 1 to 4.  You will
have to conver the pallette from a 64x64x64x4 format to a 64x64x64 format
which means that every fourth value of the former will become a single
value in the latter.

   James Lee -- j...@math.purdue.edu -- PU Math Dept Computer Consultant
WLCSC Systems Administrator -- ad...@wl.k12.in.us - WS/LAN Systems Operator
      -- work ph# (4-6pm) 49-44246, (other) 497-1289, FAX 463-2336 --
        -- http://www.math.purdue.edu/~jlee - Finger for PGP Key --
   James Lee -- j...@math.purdue.edu -- PU Math Dept Computer Consultant
WLCSC Systems Administrator -- ad...@wl.k12.in.us - WS/LAN Systems Operator
      -- work ph# (4-6pm) 49-44246, (other) 497-1289, FAX 463-2336 --
        -- http://www.math.purdue.edu/~jlee - Finger for PGP Key --

Re:Mode $13 palette problems


====quote====
Hi all, Well, my problem is that I designed a program to load a 256 color
image file, and display it on screen. (happens to be grayscale) - So all
the
palette entries should be like :
Index  Red Green Blue
1       1    1     1
2       2    2     2
.
.
.
n       n    n     n
To 255.
This is right isn't it?
====unquote====

Actually, you came to the same dilemma I came to!  The range of values for
R,G, and B in each of the 256 indices of the pallete is from 0 to 63....
I had to compensate in the same way you did by dividing by 4 when
displaying an image file (actually, I found that dividing by five gave
better results)....  My documentation says that the range is only 0..63 -
dunno....

JW

Other Threads