C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Converting Image To Graycode


Posted Date: 21 May 2008    Resource Type: Code Snippets    Category: Images
Author: vivekMember Level: Bronze    
Rating: Points: 10



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace LabMaster
{
public partial class gray : Form
{
public gray()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
bitmapmakegrayscale(pictureBox1.Image );

}

private void bitmapmakegrayscale(Image imagei)
{
Bitmap image = imagei as Bitmap;
Bitmap bp = new Bitmap(image.Width,image .Height );
for (int i = 0; i < image.Width; i++)
{
for (int j = 0; j < image.Height; j++)
{
Color orgcol = image.GetPixel(i, j);
int grayscale = (int)((orgcol.R * .3)+(orgcol.G * .59)+(orgcol.B * .11));
Color newcol = Color.FromArgb(grayscale, grayscale, grayscale);
bp.SetPixel(i, j, newcol);
}
}
pictureBox2.Image = bp;
}


}
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to Split multipage image into single page image
Previous Resource: Save Images to a Table using VB.NET
Return to Discussion Resource Index
Post New Resource
Category: Images


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use