Board index » delphi » TImage color problem changing forms in 256 color mode

TImage color problem changing forms in 256 color mode

Hello,
I'am having a problem as follows:

Delphi 3.0, Windows 95, System running in 256 color 640x480 mode.
 An application with two forms. On Form1 I have a TImage with a 256 bit BMP
picture, a webbrowser encapsulating component and a button.

With the button on Form1, I show Form2 which has a TImage with a 256 BMP
picture and a button  to close/hide Form2.

The problem:
When closing Form2 with its button, the colors in the pictures on Form1
revert from positive to negative and back to positive.

This only happens when the system is in 256 color mode. With the system in
Hi Color (16 bit) mode the application works fine.
Some customers use 256 color mode :-(

Please help

Bert

 

Re:TImage color problem changing forms in 256 color mode


On Sun, 21 Dec 1997 13:25:49 +0100, "Bert Gordijn" <l.gord...@tip.nl>
wrote:

Quote
>Hello,
>I'am having a problem as follows:

[...snipped...]

Quote
>This only happens when the system is in 256 color mode. With the system in
>Hi Color (16 bit) mode the application works fine.
>Some customers use 256 color mode :-(

Welcome to the wonderful world of Palettes! :-)

I don't have a solution yet, but I've been reading up on it
and see a couple of possible fixes. As soon as I find something
that works, I'll post it.

JE McTaggart

Re:TImage color problem changing forms in 256 color mode


Quote
On Sun, 21 Dec 1997 11:10:22 GMT, t...@ria.net wrote:
>On Sun, 21 Dec 1997 13:25:49 +0100, "Bert Gordijn" <l.gord...@tip.nl>
>wrote:

>>I'am having a problem as follows:

>[...snipped...]

>>This only happens when the system is in 256 color mode. With the system in
>>Hi Color (16 bit) mode the application works fine.
>>Some customers use 256 color mode :-(

>Welcome to the wonderful world of Palettes! :-)

>I don't have a solution yet, but I've been reading up on it
>and see a couple of possible fixes. As soon as I find something
>that works, I'll post it.

The fix is not to use multiple 256 color BMPs. The Windows system
palette has only 236 free slots. The window on top has first pick of
the available slots for its colors. Background windows take up
remaining slots or map their colors to the closest matching ones
already in the system palette.

When a new window becomes the foreground window, it gets first pick of
the system palette. If its colors are not already in the system
palette, Windows removes colors from the system palette, allowing the
foreground window to map its own colors. Remapping colors in the
system palette causes the background forms to look funny. It also
slows down Windows because it needs to repaint every background
window.

If your forms were to use, say, 64 colors apiece, the system palette
could accommodate both forms without remapping colors.
--
Ray Lischner (http://www.tempest-sw.com/)
Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API"

Re:TImage color problem changing forms in 256 color mode


Ray,

Thank you very much for your anwser to my question.
Happy new year.
Bert Gordijn.

Ray Lischner heeft geschreven in bericht
<34a79c81.54645...@news.proaxis.com>...

Quote
>On Sun, 21 Dec 1997 11:10:22 GMT, t...@ria.net wrote:

>>On Sun, 21 Dec 1997 13:25:49 +0100, "Bert Gordijn" <l.gord...@tip.nl>
>>wrote:

>>>I'am having a problem as follows:

>>[...snipped...]

>>>This only happens when the system is in 256 color mode. With the system
in
>>>Hi Color (16 bit) mode the application works fine.
>>>Some customers use 256 color mode :-(

Re:TImage color problem changing forms in 256 color mode


Quote
On Thu, 25 Dec 1997 19:11:49 GMT, n...@junk.mail (Ray Lischner) wrote:
>>>I'am having a problem as follows:

>>[...snipped...]

>>>This only happens when the system is in 256 color mode. With the system in
>>>Hi Color (16 bit) mode the application works fine.
>>>Some customers use 256 color mode :-(

>>Welcome to the wonderful world of Palettes! :-)

>>I don't have a solution yet, but I've been reading up on it
>>and see a couple of possible fixes. As soon as I find something
>>that works, I'll post it.

>The fix is not to use multiple 256 color BMPs.

True.

Quote
>The Windows system
>palette has only 236 free slots. The window on top has first pick of
>the available slots for its colors. Background windows take up
>remaining slots or map their colors to the closest matching ones
>already in the system palette.

Actually, the fix is to use no 256 color BMPs and to just keep it
simple. I've found that even one will re-arrange the palette, if it
has  < 236 color. It doesn't matter where it's located, top of z-order
or bottom....

Quote
>When a new window becomes the foreground window, it gets first pick of
>the system palette. If its colors are not already in the system
>palette, Windows removes colors from the system palette, allowing the
>foreground window to map its own colors. Remapping colors in the
>system palette causes the background forms to look funny. It also
>slows down Windows because it needs to repaint every background
>window.
>If your forms were to use, say, 64 colors apiece, the system palette
>could accommodate both forms without remapping colors.

As I said in another post, 4 forms, one graphic. One simple little 47
color bitmap. :-)

JE McTaggart

Other Threads