bitmap is the wrong color

S

Steve Richter

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(this.Handle, bm.GetHbitmap( ), bm.Width, bm.Height);
 
S

Steve Richter

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top