Board index » delphi » Pallete

Pallete

Hi guys,

How do I draw the pallete on a panel for instance?
Like, if the computer has 256 colors I draw all the colors on the
canvas of the panel? Like when we chose a color from custom color
dialog?

 

Re:Pallete


"Miguel D. T. Junior" <migu...@fnde.gov.br> wrote in message
news:3b2f416a.2878220@newsgroups.borland.com...

Quote
> How do I draw the pallete on a panel for instance?
> Like, if the computer has 256 colors I draw all the colors on the
> canvas of the panel? Like when we chose a color from custom color
> dialog?

Working with palettes can be a real pain.  I'd recommend avoiding them
whenever possible by using pf24bit bitmaps in high/true color display modes.

You are working in 256-color mode?  [Palettes don't exist in high/true color
display modes.]

Find an example here of how to display a palette:
http://homepages.borland.com/efg2lab/Graphics/Colors/PaletteLab.htm

There is other information about using palettes in Delphi on this page:
http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/Color.htm

--
efg -- Earl F. Glynn, Overland Park, KS  USA
efg's Computer Lab Mirror:  http://homepages.borland.com/efg2lab

Re:Pallete


Thx.

I'll look at the program latter. I think I can solve my problem
without getting all the colors of my computer. Let me tell about my
problem: I'm making a program that analyses graphics from stock
market. I'm beginning with a easy technique. I have to plot the same
line of a graphic just 5 pixels above the original. Well, I got this
graphic from a file like a GIF or BMP. Then I have identify the line I
want to duplicate. I do that by searching every pixel on the picture
telling the color I want to watch and then I copy every Point (TPoint)
to an array of TPoints. Well, it's almost working... The problem is
that the line I want have more than one colour cause of it's early
drawing. Not red or blue... Just imagine u scanned a graphic and it
has some gray levels at the main line... How can I search my picture
for a range of color values? like from 30 to 32? I'm having trouble to
do that cause I have some doubts about HEX.... take a look...

here is how I take all colors from my graphic (BMP)

Var
   myHeight, myWidth : Integer;
   x,y : Integer;
Begin
//colorList is a TStringList to hold all colors...
//myScreen is a TPaintBox thar I made a copyRect from a TImage
   myHeight := myScreen.Height;
   myWidth := myScreen.Width;
   for x := 0 to myWidth do
   Begin
      For y := 0 to myHeight do
         colorList.Add(ColorToString( myScreen.Canvas.Pixels[x,y]) + '
= colorX');
   End;

Now I know that my line has the color $00887468 for instance, but it
also has $00B8C0B0. How do I know that this two color are on the same
range?

Quote
>"Miguel D. T. Junior" <migu...@fnde.gov.br> wrote in message
>news:3b2f416a.2878220@newsgroups.borland.com...

>> How do I draw the pallete on a panel for instance?
>> Like, if the computer has 256 colors I draw all the colors on the
>> canvas of the panel? Like when we chose a color from custom color
>> dialog?

>Working with palettes can be a real pain.  I'd recommend avoiding them
>whenever possible by using pf24bit bitmaps in high/true color display modes.

>You are working in 256-color mode?  [Palettes don't exist in high/true color
>display modes.]

>Find an example here of how to display a palette:
>http://homepages.borland.com/efg2lab/Graphics/Colors/PaletteLab.htm

>There is other information about using palettes in Delphi on this page:
>http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/Color.htm

>--
>efg -- Earl F. Glynn, Overland Park, KS  USA
>efg's Computer Lab Mirror:  http://homepages.borland.com/efg2lab

Re:Pallete


"Miguel D. T. Junior" <migu...@fnde.gov.br> wrote in message
news:3b2fade9.30656922@newsgroups.borland.com...

Quote
> How can I search my picture
> for a range of color values? like from 30 to 32? I'm having trouble to
> do that cause I have some doubts about HEX.... take a look...
>       For y := 0 to myHeight do
>          colorList.Add(ColorToString( myScreen.Canvas.Pixels[x,y]) + '
> = colorX');

Using the Canvas.Pixels property is  very slow.  You should use Scanline
for quick access to the pixel data.
http://homepages.borland.com/efg2lab/ImageProcessing/Scanline.htm

This TechNote explains how to access the pixel data, but remember
the "pixel" data for a pf8bit bitmap is just an index into the palette
table.  The "pixel" data for a pf24bit bitmap contains the complete
color information in the TRGBTriple.

What is the PixelFormat of the BMP you're working with?

--
efg -- Earl F. Glynn, Overland Park, KS  USA
efg's Computer Lab Mirror:  http://homepages.borland.com/efg2lab

Other Threads