SoFunction
Updated on 2025-03-06

(c#) Example of programming method to convert color pictures into grayscale pictures

This article describes the method of (c#) programming to convert color pictures into grayscale pictures. Share it for your reference, as follows:

The code is as follows:

using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace WebApplication2
{
  public partial class _Default : 
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      Bitmap b = new Bitmap((""));
      for (int x = 0; x < ; x++)
      {
        for (int y = 0; y < ; y++)
        {
          Color pixel = (x, y);
          int val = ( +  + ) / 3;
          (x, y, (val, val, val));
        }
      }
      ((""));
    }
  }
}

For more information about C# related content, please check out the topic of this site:Summary of C# picture operation skills》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《C# data structure and algorithm tutorial》、《Introduction to C# object-oriented programming tutorial"and"Summary of thread usage techniques for C# programming

I hope this article will be helpful to everyone's C# programming.