zoukankan      html  css  js  c++  java
  • asp.net(c#)将彩色图片变灰阶图片

    代码如下:

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Drawing;
    using System.Drawing.Imaging;
    /* 何问起 hovertree.com */
    namespace WebApplication2
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                Bitmap b = new Bitmap(Server.MapPath("01.jpg"));
    
    
                for (int x = 0; x < b.Width; x++)
                {
                    for (int y = 0; y < b.Height; y++)
                    {
    
    
                        Color pixel = b.GetPixel(x, y);
    
    
    
    
                        int val = (pixel.R + pixel.G + pixel.B) / 3;
    
    
    
    
    
    
                        b.SetPixel(x, y, Color.FromArgb(val, val, val));
    
    
                    }
                }
    
    
                b.Save(Server.MapPath("1.jpg"));
    
    
            }
        }
    }

    推荐:http://www.cnblogs.com/roucheng/p/3518068.html

  • 相关阅读:
    密码学基础(三)
    密码学基础(二)
    密码学基础(一)
    Lambda代数
    恢复系统
    11.22面试例题
    js中级复习
    11.12
    11.13
    定时器
  • 原文地址:https://www.cnblogs.com/roucheng/p/csheibai.html
Copyright © 2011-2022 走看看