Groups | Blog | Home
all groups > dotnet compact framework > february 2005 >

dotnet compact framework : How do draw an image in a disabled state?


Dan
2/18/2005 9:53:41 PM
Hi everyone

Does anyone know how to draw an image in a disabled state on the compact
framework?
I have created a dropdown button akin to the forward and back button in IE
but I'm stuck when it comes to putting the button in a disabled state.

Any help would be much appreciated.
Thanks in advance
Dan

Daniel Moth
2/18/2005 11:54:20 PM
The Control.Enabled property (=false) should do it... or just create a copy
of your image replacing all white with the light grey and every other color
with dark grey.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


[quoted text, click to view]
Dan
2/19/2005 1:36:42 AM
Arh I did wonder if the easiest way would just be to have a copy of the
image, I know how to do it in the full framework for changing it on the fly
on just one image.

Dan

[quoted text, click to view]

Dan
2/19/2005 10:00:53 AM
Hi Sergey

That worked first time thats brilliant, thanks a lot.

Thanks again
Dan

[quoted text, click to view]
Sergey Bogdanov
2/19/2005 11:25:35 AM
So it will get like disabled, convert a certain Image as grayscale by
computing Y value (is the grayscale component in YIQ) by this formula:

Y = 0.299 * R + 0.587 * G + 0.114 * B

and then use Y value as R, G, B parameters for a color. See the code
snippet bellow, "dst" variable will contain grayscale image from
"source" bitmap:

Bitmap dst = new Bitmap(source.Width, source.Height);

for(int y=0; y < dst.Height;y++)
{
for(int x=0; x < dst.Width; x++)
{
Color c = source.GetPixel(x, y);
// alternatively Y = (77 * c.R + 150 * c.G + 29 * c.B) >> 8
int Y = (int)(c.R * 0.299 + c.G * 0.587 + c.B * 0.114);
dst.SetPixel(x, y, Color.FromArgb(Y, Y, Y));
}
}


Hope this help,
Sergey Bogdanov
http://www.sergeybogdanov.com


[quoted text, click to view]
AddThis Social Bookmark Button