c#图片色阶调整、亮度调整

本文介绍如何使用C#进行图片的色阶和亮度调整,包括读取图片、调整色阶和亮度以及保存图片的代码实现。
摘要由CSDN通过智能技术生成
static void Main()  
{  
    Bitmap aa = file2img("test.jpg");  
    Bitmap cc = img_color_gradation(aa,100,0,0);  
    img2file(cc, "test1.jpg");  
}  

色阶调整代码

public static unsafe Bitmap img_color_gradation(Bitmap src, int r, int g, int b)  
{  
    int width = src.Width;  
    int height = src.Height;  
    Bitmap back = new Bitmap(width, height);  
    Rectangle rect = new Rectangle(0, 0, width, height);  
    //这种速度最快  
    BitmapData bmpData = src.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);//24位rgb显示一个像素,即一个像素点3个字节,每个字节是BGR分量。Format32bppRgb是用4个字节表示一个像素  
    byte* ptr = (byte*)(bmpData.Scan0);  
    for (int j = 0; j < height; j++)  
    {  
        for (int i = 0; i < width; i++)  
        {  
            //ptr[2]为r值,ptr[1]为g值,ptr[0]为b值  
            int red = ptr[
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值