原文发布时间为:2009-01-16 —— 来源于本人的百度文章 [由搬家工具导入]

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 neicun
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap m_Bmp = new Bitmap("d:\\nvhai.bmp");//锁定位图像素
            int h = m_Bmp.Height;
            int w = m_Bmp.Width;

            Bitmap bmpOut = new Bitmap(w, h, PixelFormat.Format24bppRgb);

            BitmapData dataIn = m_Bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
            BitmapData dataOut = bmpOut.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            unsafe
            {
                byte* pIn = (byte*)(dataIn.Scan0.ToPointer());
                byte* pOut = (byte*)(dataOut.Scan0.ToPointer());

                for (int y = 0; y < dataIn.Height; y++)
                {
                    for (int x = 0; x < dataIn.Width; x++)
                    {

                        pOut[0] = (byte)(255 - pIn[0]);
                        pOut[1] = (byte)(255 - pIn[1]);
                        pOut[2] = (byte)(255 - pIn[2]);

                        pIn += 3;
                        pOut += 3;
                    }

                    pIn += dataIn.Stride - dataIn.Width * 3;
                    pOut += dataOut.Stride - dataOut.Width * 3;
                }
            }

            bmpOut.UnlockBits(dataOut);
            m_Bmp.UnlockBits(dataIn);
            pictureBox1.Image = bmpOut;
        }
    }
}

BitmapData处理图像例子【逆反处理】的更多相关文章

  1. paper 119:[转]图像处理中不适定问题-图像建模与反问题处理

    图像处理中不适定问题 作者:肖亮博士 发布时间:09-10-25 图像处理中不适定问题(ill posed problem)或称为反问题(inverse Problem)的研究从20世纪末成为国际上的 ...

  2. pytorch标准化后的图像数据如果反标准化保存

    1.数据处理代码utils.py: 1) # coding:utf- import os import torch.nn as nn import numpy as np import scipy.m ...

  3. lombok @Builder注解使用的例子、反编译之后的代码详解

    lombok的@Builder实际是建造者模式的一个变种,所以在创建复杂对象时常使用 这里对lombok的@Builder和@Data组合的使用示例 import lombok.Builder; im ...

  4. LeetCode:151_Reverse Words in a String | 字符串中单词的逆反 | Medium

    题目:Reverse Words in a String Given an input string, reverse the string word by word. For example, Gi ...

  5. paper 89:视频图像去模糊常用处理方法

    随着“平安城市”的广泛建设,各大城市已经建有大量的视频监控系统,虽然监控系统己经广泛地存在于银行.商场.车站和交通路口等公共场所,但是在公安工作中,由于设备或者其他条件的限制,案情发生后的图像回放都存 ...

  6. Why数学图像生成工具

    该软件能够以给定的数学公式及算法生成各种绚烂的数学图像.软件中有两种生成图像的方法: (1)通过一种我自定义的脚本语言生成: 软件中定义一套简单易学的脚本语言,用于描述数学表达式.使用时需要先要将数学 ...

  7. [ActionScript 3.0] AS3.0将图像的Alpha通道转换为黑白图像(复制通道方式)

    import flash.display.BitmapData; /** * 将图像的Alpha通道转换为黑白图像 */ var p:Point = new Point(0,0); var bmpd: ...

  8. 使用Html5+C#+微信 开发移动端游戏详细教程 :(五)游戏图像的加载与操作

    当我们进入游戏时,是不可能看到所有的图像的,很多图像都是随着游戏功能的打开而出现, 比如只有我打开了"宝石"菜单才会显示宝石的图像,如果是需要显示的时候才加载, 会对用户体验大打折 ...

  9. DSAPI多功能组件编程应用-图形图像篇(中)

    [DSAPI.DLL下载地址]   说到计算机上使用代码来处理各种图像特效,是一份太有挑战性的工作.以下涉及的所有图像效果均不是从网上复制的源码,而是本人试验数次并编写的,所以原理上会和网上的有所不同 ...

随机推荐

  1. jenkins重置build序号

    来源:https://www.jianshu.com/p/e342b52d45e1 执行命令:item = Jenkins.instance.getItemByFullName("your- ...

  2. Apache 配置默认编码

    找到apache配置文件 httpd.conf ,找到以下内容 # # Specify a default charset for all content served; this enables # ...

  3. [译]The Python Tutorial#12. Virtual Environments and Packages

    [译]The Python Tutorial#Virtual Environments and Packages 12.1 Introduction Python应用经常使用不属于标准库的包和模块.应 ...

  4. 多线程并发测试(apache ad)

    1.配置 ThreadPoolTaskExecutor bean   <?xml version="1.0" encoding="UTF-8"?> ...

  5. django之配置静态文件

    # 别名 STATIC_URL = '/static/' # 配置静态文件,名字必须是STATICFILES_DIRS STATICFILES_DIRS = [ os.path.join(BASE_D ...

  6. The Suspects POJ 1611

    The Suspects Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, w ...

  7. Hive UDTF开发指南

    在这篇文章中,我们将深入了解用户定义表函数(UDTF),该函数的实现是通过继承org.apache.Hadoop.hive.ql.udf.generic.GenericUDTF这个抽象通用类,UDTF ...

  8. 数据库——初始mysql语句(2)

    sql语句 #1. 操作文件夹(库) 增:create database db1 charset utf8; 查:show create database db1; show databases; 改 ...

  9. [python][django 1.10中文文档]

    https://docs.djangoproject.com/en/1.10/  官方文档,点我下载 推荐一个翻译django 1.8.2的网址: 推荐一个翻译django 1.10的博客:(着重推荐 ...

  10. 错误:支持“EFDbContext”上下文的模型已在数据库创建后发生更改。请考虑使用 Code First 迁移更新数据库(http://go.microsoft.com/fwlink/?LinkId

    支持"EFDbContext"上下文的模型已在数据库创建后发生更改.请考虑使用 Code First 迁移更新数据库(http://go.microsoft.com/fwlink/ ...