bitmap is the wrong color

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Richter

    bitmap is the wrong color

    using SetPixel to set all the pixels of a bitmap to Color.Red.
    Problem is the bitmap displays as Color.Turqoise.

    if all the pixels of the bitmap are Red, why does it not display as
    Red?

    thanks,

    Bitmap bm = new Bitmap(5, 12 );

    // set the bitmap pixels to color.Red
    for (int x = 0; x < bm.Width; x++)
    {
    for (int y = 0; y < bm.Height; y++)
    {
    bm.SetPixel(x, y, Color.Red);
    }
    }

    CreateCaret(thi s.Handle, bm.GetHbitmap( ), bm.Width, bm.Height);
  • Peter Duniho

    #2
    Re: bitmap is the wrong color

    On Tue, 01 Apr 2008 12:36:40 -0700, Steve Richter
    <StephenRichter @gmail.comwrote :
    using SetPixel to set all the pixels of a bitmap to Color.Red.
    Problem is the bitmap displays as Color.Turqoise.
    >
    if all the pixels of the bitmap are Red, why does it not display as
    Red?
    What happens if you try to just display the Bitmap instance conventionally?

    I suspect that the caret implementation is using some transformation (XOR,
    NOT, etc.) to ensure that it's visible over whatever content is in the
    window where you're showing the caret. It's unlikely to have anything to
    do with how you're creating the Bitmap instance, but rather how you're
    using it.

    Given that your usage of the bitmap has nothing to do with C# or .NET per
    se, I think your question is likely to get a better answer if you ask in a
    newsgroup specific to unmanaged Windows programming.

    Pete

    Comment

    • Steve Richter

      #3
      Re: bitmap is the wrong color

      On Apr 1, 3:41 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
      wrote:
      On Tue, 01 Apr 2008 12:36:40 -0700, Steve Richter  
      >
      <StephenRich... @gmail.comwrote :
      using SetPixel to set all the pixels of a bitmap to Color.Red.
      Problem is the bitmap displays as Color.Turqoise.
      >
      if all the pixels of the bitmap are Red, why does it not display as
      Red?
      >
      What happens if you try to just display the Bitmap instance conventionally?
      it is red! problem solved.
      >
      I suspect that the caret implementation is using some transformation (XOR, 
      NOT, etc.) to ensure that it's visible over whatever content is in the  
      window where you're showing the caret.  It's unlikely to have anything to  
      do with how you're creating the Bitmap instance, but rather how you're  
      using it.
      >
      Given that your usage of the bitmap has nothing to do with C# or .NET per  
      se, I think your question is likely to get a better answer if you ask in a 
      newsgroup specific to unmanaged Windows programming.
      will do, thanks.


      Comment

      Working...