PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms WHY? - Colors of bitmap are shown inverted sometimes.

Reply

WHY? - Colors of bitmap are shown inverted sometimes.

 
Thread Tools Rate Thread
Old 25-06-2003, 07:26 PM   #1
Lee Gillie
Guest
 
Posts: n/a
Default WHY? - Colors of bitmap are shown inverted sometimes.


I'm making a custom control. It draws a bitmap in OnPaint, then draws text
over it. This worked fine until I started embellishing the application which
uses the control. At times the image is shown with inverted colors.

Typically it happens when some other form is involved. For example, when I
use the print dialog, after the printing is done, it repaints the area the
print dialogs were shown, and the image is suddenly inverted. Another time
is in implementing a FIND function to search text, which is displayed over
the bitmap. When my FIND dialog closes, the image is shown inverted.
Sometimes I can do something that causes a repaint, and get it returned to
normal, but sometimes the inverted colors stick.

I am disposing every resource created with "New" in my OnPaint prior to exit
of the routine, and doing so in reverse order of creation. All of this is
bracketed within BeginContainer and EndContainer. I am using something I
found for flicker-free display in my NEW() sub for the control:

SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)

What could be causing the inverted colors?


  Reply With Quote
Old 26-06-2003, 01:55 PM   #2
Colin Young
Guest
 
Posts: n/a
Default Re: WHY? - Colors of bitmap are shown inverted sometimes.

Have you looked at any other commercial apps that display images to see if
they exhibit the same behaviour? Could you create a "user initiated twiddle"
in code to clear it up?

To be honest, if one is still using 8-bit displays, it's not likely one is
doing any critical image work, so at worst this problem is an annoyance.

Can you still buy 8-bit video cards?

Colin

"Lee Gillie" <DESPAMlee@odp.comMAPSED> wrote in message
news:%23fnmCy1ODHA.3088@TK2MSFTNGP10.phx.gbl...
> Ok, I found discussion of GetHalftonePalette in the documentation. I don't
> entirely understand what it does. It does not eliminate the problem, but

it
> makes it much less severe. A user can twiddle a bit, to cause a repaint,

and
> everything is pretty close then. It no longer gets "stuck", and sometimes

it
> does not happen at all now. I find that after printing, though, it is
> initially still in this odd palette condition until a user initiated

twiddle
> is done.
>
> I see very little discussion of this issue in .NET documentation or
> discussion groups, which leads me to believe it is not a pervasive

problem.
> But those developing software for the masses should realize the need to

test
> on 8-bit displays, to be sure their software will run on all kinds of

iron.
>
> If there is a better way to deal with this, I'd sure like to know.
>
> Best regards - Lee Gillie
>
>



  Reply With Quote
Old 26-06-2003, 06:22 PM   #3
100
Guest
 
Posts: n/a
Default Re: WHY? - Colors of bitmap are shown inverted sometimes.

Hi Lee,
Actually I don't know how it works on GDI+, but in GDI when you use display
mode,which uses palettes (like in your case with 256 colors) you have to
load the system (hardware) palette every time your window becomes active. As
long as all application share the same hardware palette the colors are kind
of insufficient. That's why only the active window uses the colors its
actually needs. And the application's responsibility is to load the hardware
palette with correct values The GDI function for doing this is called
RealizePalette.
So you might check in the .NET and GDI+ documentation if it still works like
this.

HTH
100

"Lee Gillie" <DESPAMlee@odp.comMAPSED> wrote in message
news:eUoP0%230ODHA.1720@TK2MSFTNGP11.phx.gbl...
> I'm making a custom control. It draws a bitmap in OnPaint, then draws text
> over it. This worked fine until I started embellishing the application

which
> uses the control. At times the image is shown with inverted colors.
>
> Typically it happens when some other form is involved. For example, when I
> use the print dialog, after the printing is done, it repaints the area the
> print dialogs were shown, and the image is suddenly inverted. Another time
> is in implementing a FIND function to search text, which is displayed over
> the bitmap. When my FIND dialog closes, the image is shown inverted.
> Sometimes I can do something that causes a repaint, and get it returned to
> normal, but sometimes the inverted colors stick.
>
> I am disposing every resource created with "New" in my OnPaint prior to

exit
> of the routine, and doing so in reverse order of creation. All of this is
> bracketed within BeginContainer and EndContainer. I am using something I
> found for flicker-free display in my NEW() sub for the control:
>
> SetStyle(ControlStyles.DoubleBuffer, True)
> SetStyle(ControlStyles.AllPaintingInWmPaint, True)
>
> What could be causing the inverted colors?
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off