Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / March 2007

Tip: Looking for answers? Try searching our database.

Greyed Image?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ole - 29 Mar 2007 09:43 GMT
How to grey an image on a e.g. a custom button?

Thanks,
Ole
<ctacke/> - 29 Mar 2007 13:20 GMT
You need a separate image with the grey colors and you paint it instead of
the color version when you want.

Signature

Chris Tacke - Embedded MVP
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--

> How to grey an image on a e.g. a custom button?
>
> Thanks,
> Ole
Peter Schottland - 30 Mar 2007 08:04 GMT
Here's a simple algorithm for doing greyscale:

 static public Bitmap BitmapGrayScaleWeighted(Bitmap colorBitmap)
 {
  if (colorBitmap == null)
   throw new ArgumentNullException("colorBitmap",
"ImageTools.BitmapGrayScaleWeighted");

  Bitmap grayBitmap = new Bitmap(colorBitmap.Width, colorBitmap.Height);

  Color colorPixel;
  int newRGB;

  for (int y = 0; (y < colorBitmap.Height); y++)
   for (int x = 0; (x < colorBitmap.Width); x++)
   {
    colorPixel = colorBitmap.GetPixel(x, y);
    newRGB = (int)((0.212671 * colorPixel.R) + (0.715160 * colorPixel.G) +
(0.072169 * colorPixel.B));
    grayBitmap.SetPixel(x, y, Color.FromArgb(newRGB, newRGB, newRGB));
   }

  return grayBitmap;
 }

-peter

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.