RGB 256-color palette problem 
Author Message
 RGB 256-color palette problem

hi! i program using FreePascal and TP7 in DOS. i have a problem
regarding using using the 256-color palette. though i am tired of using
only 256 colors (i use high-color), i want to support this the VESA
256-color modes. i know how to set, get the palette values in these
modes. but what i want is to support RGB in all modes be it high-color
or 256 color modes. i want to create a 256 color palette that has all
(meaning nearest) possible RGB range of colors. with this i can supply
RGB value to my 'SetColorRGBblahblah()' then this routine could match
the nearest palette number of the color containing the nearest color
with the supplied RGB value. Say i want to load a truecolor BMP in 256
color mode, what we will do is to plot each pixel in a color that is
nearest to RGB read from the file. This kind of algorithm maybe far
from dithering that windows do but it can be good. if someone knows how
to match (fast routines) the RGB in the palette, please help me. Or
better if someone could help me with the basics of dithering. Thanks!

-dexter

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 RGB 256-color palette problem
hi dexter,


Quote:
> hi! i program using FreePascal and TP7 in DOS. i have a problem
> regarding using using the 256-color palette. though i am tired of using
> only 256 colors (i use high-color), i want to support this the VESA
> 256-color modes. i know how to set, get the palette values in these
> modes. but what i want is to support RGB in all modes be it high-color
> or 256 color modes. i want to create a 256 color palette that has all
> (meaning nearest) possible RGB range of colors. with this i can supply
> RGB value to my 'SetColorRGBblahblah()' then this routine could match
> the nearest palette number of the color containing the nearest color
> with the supplied RGB value. Say i want to load a truecolor BMP in 256
> color mode, what we will do is to plot each pixel in a color that is
> nearest to RGB read from the file. This kind of algorithm maybe far
> from dithering that windows do but it can be good. if someone knows how
> to match (fast routines) the RGB in the palette, please help me. Or
> better if someone could help me with the basics of dithering. Thanks!

> -dexter


i would create a palette using this format 'RRRGGGBB' for the entries.

h16to8(w :word) : byte; {RRRRRGGGGGGBBBBB -> RRRGGGBB}
begin
  h16to8 := ((w and $e000) shr 8)
    or ((w and $700) shr 6)
    or ((w and $18) shr 3)
end;

this code you can easly transform to assembler to fasten.

and for 15 bit (32768 colors) :

h15to8(w :word) : byte; {ARRRRRGG|GGGBBBBB -> RRRGGGBB}
begin
  h15to8 := ((w and $7000) shr 7)
    or ((w and $380) shr 5)
    or ((w and $18) shr 3)
end;

i didn't test the code so i might have counted bits wrong ;-),
but that is one way it should work.

hth
Jochen



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RGB and 256-color palette matching

2. 256 color palette

3. Please Help Me with 256 color Palette !!

4. 256 color palette in TP7

5. - 256 Color Palette Blues

6. Problem with 256-Palette

7. 256 color image on a 16 color screen?

8. 24-bit color to 256 color's source

9. Mouse in 256 color mode PROBLEM

10. 256 Colour Palette Generator

11. Help with Palette [RGB]

12. Reading in RGB Palette Successfully in TP 6.0

 

 
Powered by phpBB® Forum Software