C#读写BitMap及颜色相乘

  private Bitmap ReadBitMapAndMultipy(Bitmap bitmap0)
{
int x1width = bitmap0.Width;
int y1height = bitmap0.Height;
Bitmap image = new Bitmap(x1width, y1height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int iPixelSize = ; BitmapData bitmapdata = image.LockBits(new
Rectangle(, , x1width, y1height),
ImageLockMode.ReadWrite, image.PixelFormat);
BitmapData bitmapdata0 = bitmap0.LockBits(new
Rectangle(, , x1width, y1height),
ImageLockMode.ReadOnly, image.PixelFormat);
try
{
unsafe
{
for (int y = ; y < y1height; y++)
{
byte* row = (byte*)bitmapdata.Scan0 +
(y * bitmapdata.Stride);
byte* row0 = (byte*)bitmapdata0.Scan0 +
(y * bitmapdata0.Stride);
for (int x = ; x < x1width; x++)
{
byte tempValB = row0[x * iPixelSize];
byte tempValG = row0[x * iPixelSize + ];
byte tempValR = row0[x * iPixelSize + ];
byte tempValA = row0[x * iPixelSize + ];
double r = Convert.ToDouble(tempValR) * / ;
double g = Convert.ToDouble(tempValG) * / ;
double b = Convert.ToDouble(tempValB) * / ; //double r = Convert.ToDouble(tempValR) * 78 / 255;
//double g = Convert.ToDouble(tempValG) * 69 / 255;
//double b = Convert.ToDouble(tempValB) * 48 / 255;
row[x * iPixelSize] = (byte)(b);
row[x * iPixelSize + ] = (byte)(g);
row[x * iPixelSize + ] = (byte)(r);
row[x * iPixelSize + ] = tempValA;
}
} }
}
catch
{
}
finally
{
image.UnlockBits(bitmapdata);
}
return image;
}

ReadBitMapAndMultipy

调用的代码:

 string path = System.IO.Path.GetDirectoryName(fileName);
Image bitmap = pictureBox1.Image;
Bitmap bitmap0 = bitmap as Bitmap;
Bitmap sabe = ReadBitMapAndMultipy(bitmap0);
Guid guid = new Guid();
string file = string.Format(@"{0}\{1}.png", path, guid.ToString());
sabe.Save(file);

C#读写BitMap及颜色相乘的更多相关文章

  1. Bitmap 图片格式并用 C++ 读写 Bitmap

    转自 Bitmap 图片格式并用 C++ 读写 Bitmap 1.Bitmap 图片格式 每部分的具体内容就不展开了.要说的有两点: (1)调色板不是必须的,可有可无,有没有调色板可以通过位图文件头的 ...

  2. 如何使用Palette提取Bitmap的颜色

    5.X提出了color palette 的概念,能够让主题动态的去适应当前的页面色调,让整个app色调看起来比较和谐统一 那么如何使用Palette呢,必不可少,我们需要在Android studio ...

  3. directX学习系列8 颜色融合(转)

    1, Multipass(多通道)    将一个任务划分成几个阶段,由多个pass处理不同阶段,后续pass总是处理前一个pass的结果.例如复杂的光照方程可以分成几个pass来计算.    用不同的 ...

  4. SharpDX之Direct2D教程I——简单示例和Color(颜色)

    研究Direct2D已经有一段时间了,也写了一个系列的文章 Direct2D ,是基于Windows API Code Pack 1.1.在前文 Direct2D教程VIII——几何(Geometry ...

  5. OpenGL — GLFW — 颜色

    OpenGL - GLFW - 颜色 参考教程:https://learnopengl-cn.readthedocs.io/zh/latest/02%20Lighting/01%20Colors/ 既 ...

  6. OpenGL光照1:颜色和基础光照

    本文是个人学习记录,学习建议看教程 https://learnopengl-cn.github.io/ 非常感谢原作者JoeyDeVries和多为中文翻译者提供的优质教程 的内容为插入注释,可以先跳过 ...

  7. Shader 中的颜色计算

    下面介绍 Shader 中 gl_FragColor 的计算与转换: 一.颜色计算 1. 加 这里要讲讲三原色和三基色:三原色一般指的是红.绿.蓝三种,简称 RGB,这是加色系.就是光源只含有特定的波 ...

  8. 一个使用openGL渲染的炫丽Android动画库

    android-magic-surface-view 这是一个 android 动画特效库, 可以实现各种炫酷动画. github地址: https://github.com/gplibs/andro ...

  9. ImageLoader 笔记

    BitmapFactory 我们不能够通过构造函数创建Bitmap对象.如果需要将图片转成Bitmap对象加载到内存中,就需要使用BitmapFactory类.BitmapFactory跟据图片数据源 ...

随机推荐

  1. JSValidation客户端验证框架

    下载 引入文件 <script src="/Example4/js/validation-framework.js"></script> <!DOCT ...

  2. 从个人的角度谈谈本次GNTC大会的收获

    GNTC资料:from sdnlab 从个人的角度谈谈本次大会的收获 从本次大会的主题演讲来看,目前SDN.NFV的最前沿已经不再像五年前持观望态度以及探讨,各大运营商.各大厂商已经将SDN.NFV具 ...

  3. Ubuntu/linux 安装 kernel-devel

    这个问题,需要安装与系统内核配套的开发包. 查看内核: uname -r 内核头文件C header files下载地址: http://rpmfind.net/linux/rpm2html/sear ...

  4. PHP 错误与异常 笔记与总结(7)将错误日志以邮件方式发送

    当系统发生了很严重的问题,需要立刻发送给管理员.可以通过 error_log() 将错误以邮件形式发送到邮箱. 在 php.ini 中设置: sendmail_from = 472323087@qq. ...

  5. ThinkPHP公共配置文件与各自项目中配置文件组合的方法

    ThinkPHP公共配置文件与各自项目中配置文件组合的方法 文章TAG:thinkphp 公共配置文件 时间:2014-11-25来源:www.aspku.com 作者:源码库 文章热度: 146 ℃ ...

  6. Least_squares 最小二乘法

    https://en.wikipedia.org/wiki/Least_squares 動差估計法( MM, The Method of Moment ) 最小平方法( LSQ, The Method ...

  7. a computer-centered view of information systems to a database-centered view

    Code.Complete.Second.Edition 2004 Bachman compared the Ptolemaic-to-Copernican change in astronomy t ...

  8. P1149 火柴棒等式

    #include <bits/stdc++.h> using namespace std; const int num[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6} ...

  9. Java 遍历Map时 删除元素

    Java代码   package,,,,,,,,,,,==){ System.out.println("delete this: "+key+" = "+key ...

  10. 【转】 Build a RESTful Web service using Jersey and Apache Tomcat 2009

    Build a RESTful Web service using Jersey and Apache Tomcat Yi Ming Huang with Dong Fei Wu, Qing GuoP ...