white bitmap is not 100% white

J

Jacco

Hi,

When I display a picture and load a bitmap with whites in it (in fact, a big
white area), and I compare thet white with the full white of the panel
behind it, I see that the bitmap is not exactly white. Is there some color
conversion in the PDA device ? How can I force a full white pixel in a
bitmap to display as the same white as the rest of my application?

Thanks!
Jacco

I use vb .net 2003 to write an application in the compact framework.
 
B

Boris Nienke

AHA!
Now that's interesting!
Yesterday evening i've build up a cool startup bitmap for a splash
screen... but on the device it looks a bit "ugly / dirty" ... and i have
searched and thought WHY THE HELL... but now it's clear :'(

Does anyone have some code to work-around that? (code example to use the
native API to set the pixeldepth to 24bit)

Boris
 
J

Jacco

Chris, thanks for the link!

but...
since this is a 'known issue' for more than 10 months now...there must be
some lost soul on this planet to have found a workaround? anyone? :D

Jacco.
 
É

éric

Make your bitmap a gif with a transparent attribute
or
use something like this to draw with a transparent attribute...
this is from someone's image button code I found posted here but it can help
you draw with transparency.

protected override void OnPaint(PaintEventArgs e )
{
Graphics gxOff; //Offscreen graphics
Rectangle imgRect; //image rectangle
Brush backBrush; //brush for filling a backcolor
if (m_bmpOffscreen == null) //Bitmap for doublebuffering
{
m_bmpOffscreen = new Bitmap(ClientSize.Width, ClientSize.Height);
}
gxOff = Graphics.FromImage(m_bmpOffscreen);
gxOff.Clear(BackColor);
if (!bPushed)
backBrush = new SolidBrush(Parent.BackColor);
else //change the background when it's pressed
backBrush = new SolidBrush(Color.White);
gxOff.FillRectangle(backBrush, ClientRectangle);
if (image != null)
{
//Center the image relativelly to the control
int imageLeft = (Width - image.Width) / 2;
int imageTop = (Height - image.Height) / 2;
imgRect = new Rectangle(imageLeft , imageTop , image.Width,
image.Height);
//Set transparent key
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorKey(BackgroundImageColor(image),
BackgroundImageColor(image));
//Draw image
gxOff.DrawImage(image, imgRect, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel, imageAttr);
}
else
{
}
//Draw from the memory bitmap
e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
base.OnPaint(e);
}
protected override void OnPaintBackground(PaintEventArgs e )
{
//Do nothing
}
private Color BackgroundImageColor(Image image)
{
Bitmap bmp = new Bitmap(image);
return bmp.GetPixel(0, 0);
}
 
B

Boris Nienke

Make your bitmap a gif with a transparent attribute
or
use something like this to draw with a transparent attribute...
this is from someone's image button code I found posted here but it can help
you draw with transparency.

AFAIK the transparency is not the problem... the problem is, that you
define a part of a bitmap as white (255,255,255) but then it isn't
displayed as white but as some kind of gray. The same for other colors

I have a bitmap with lots of gradients in brown, yellow and blue... in this
case i don't need a transparent feature ... :) i just like it to be
displayed as i've designed it on my PC ;-)

Boris
 
G

Geoff Schwab [MSFT]

Hi Boris,

This is simply not possible due to the limitations of the hardware.
Remember that you are taking a bitmap that you have viewed on a display
capable of displaying 24, and most likely 32 bit images and putting it on a
device that is only capable of displaying 16 bit graphics. Just be thankful
you are not working on a video game system that has to display it on an NTSC
screen!

When the pixels are converted, they are "rounded down" so if you want to
preview the graphics on the desktop then take each pixel color and round it
off like it will be on the device. Most devices are 555 RGB formatted so if
you take each pixel, break into R,G, and B components, then right shift by 3
you should see something more similar to what it will be on the device.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Boris Nienke

Well, you are telling me things i always knew...
I'm not the OP - it was Jacco having this problem and Chris posting a
link to a discussion about that:

http://groups.google.com/groups?hl=...soft.public.dotnet.framework.compactframework

as you can read there:
- opening such picture with an viewer on the PPC is OK
- opening it in CF is "wrong"
- possible solution is to let the Device do the calculation (die Display or
the Graphic-Chip) not some code... this may be done by telling the CF
that this graphic is 24 bit
- Even with 256 color bitmaps the problem exists

After i've read this i knew what my graphic-problems in the C# applications
are.

And BTW: there are still devices out there, which have just 4096 or 256 Colors! So
creating a 16 bit bitmap wouldn't be the best way... so either you have
to create 256 color bitmaps with palette (hopefulle those devices doesn't have
a fixed palette) or using alway 24 bit true color and let the device
handle it :) ... but correctly ;) (i know that it isn't easy)

I have work-around it now by playing around with the Gama, hue, saturation,
contrast etc. on the desktop until it looks better on the PPC (in my C#
application)

Boris
 

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