Board index » delphi » Working with Palette in Delphi

Working with Palette in Delphi

If you have been able to sucessfully manipulate the color palette in a
Delphi application I need your help.

I am trying to determine if I can pull from a greater number of colors
for my project when it is running in 256 color mode.  One thought
towards this end was to experiment with the palette.  However I have had
little success in creating, or switching palettes.

Any help would be appreciated.

-----------------------------------------------------------
Tom Clowers
Systems Analyst
PC Programming Group

Expeditors International of Washington, Inc.

visit our website at http://www.expd.com
You'd be surprised how far we'll go for you.

for something different, my home page...
   http://www.wolfe.net/~tomc
===========================================================

 

Re:Working with Palette in Delphi


On Tue, 23 Jan 1996 00:20:25 -0800, Tom Clowers <t...@wolfenet.com>
wrote:

Quote
>If you have been able to sucessfully manipulate the color palette in a
>Delphi application I need your help.

>I am trying to determine if I can pull from a greater number of colors
>for my project when it is running in 256 color mode.  One thought
>towards this end was to experiment with the palette.  However I have had
>little success in creating, or switching palettes.

First you need to understand the general principles of palettes in
Windows. Look for the PW0777.EXE file at Microsoft's FTP or Web site,
in the SoftLib directory somewhere. It is a self-study course on
palettes.

Next, realize that every control in Delphi can have a palette, and if
it has one, then Delphi automatically selects and realizes it. The
control returns the palette handle with the GetPalette methods. You
can write a control to override this method.

A TBitmap object can have a palette, either by reading it from a file,
copying it from the clipboard, or setting its Palette property to a
palette handle. If a bitmap in a TImage control has a palette, then
Delphi automatically selects and realizes the palette.

--
Ray Lischner         (li...@tempest-sw.com)
Tempest Software, Corvallis, Oregon, USA

Re:Working with Palette in Delphi


Quote
li...@tempest-sw.com (Ray Lischner) wrote:
>On Tue, 23 Jan 1996 00:20:25 -0800, Tom Clowers <t...@wolfenet.com>
>wrote:

>>If you have been able to sucessfully manipulate the color palette in a
>>Delphi application I need your help.

>>I am trying to determine if I can pull from a greater number of colors
>>for my project when it is running in 256 color mode.  One thought
>>towards this end was to experiment with the palette.  However I have had
>>little success in creating, or switching palettes.

>First you need to understand the general principles of palettes in
>Windows. Look for the PW0777.EXE file at Microsoft's FTP or Web site,
>in the SoftLib directory somewhere. It is a self-study course on
>palettes.

>Next, realize that every control in Delphi can have a palette, and if
>it has one, then Delphi automatically selects and realizes it. The
>control returns the palette handle with the GetPalette methods. You
>can write a control to override this method.

>A TBitmap object can have a palette, either by reading it from a file,
>copying it from the clipboard, or setting its Palette property to a
>palette handle. If a bitmap in a TImage control has a palette, then
>Delphi automatically selects and realizes the palette.

        Good answer. For anybody who reads "A TBitmap object can have a
palette,..by...setting its Palette property to a palette handle", tries it
and concludes it doesn't work: There's a strange quirk here:

aBitmap:=TBitmap.Create;
aBitmap.Palette:=APaletteHandle;

won't work, but

aBitmap:=TBitmap.Create;
dummy:=aBitmap.Handle;
aBitmap.Palette:=APaletteHandle;

will. (Or referencing the handle in any number of other ways will do it...)

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...

Re:Working with Palette in Delphi


Is there any function i delphi tgat does the same thing tah the inp in C
does???????

Re:Working with Palette in Delphi


Quote
Claes Eriksson <claes.eriks...@telub.se> wrote:
>Is there any function i delphi tgat does the same thing tah the inp in C
>does???????

Haven't wrttin in C since delphi came out.  But if inp is reading from
an input port try this.

 Port[$3F8]      { read an 8-bit value from the port at $3F8 }
 PortW[$61]    { read a 16-bit value from  the port at $61 }

Hope this is it.

Trey Weaver

Other Threads