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. JavaScript系列:event.bubbles属性(并不是所有的事件都具有冒泡)

    地址 https://www.w3.org/TR/DOM-Level-3-Events/#h3_interface-Event https://segmentfault.com/q/101000000 ...

  2. 安装wamp,访问主页提示PHP configuration loaded file……

    安装wamp,访问主页提示PHP configuration loaded file…… *** ERROR *** The PHP configuration loaded file is: - s ...

  3. [听课笔记]Professor Michael Cusumano's New Book:" Strategy Rules: Five Timeless Lessons from Bill Gates, Andy Grove, and Steve Jobs"

    1. Look Forward, Reason Back Extrapolate, interpret, then tie vision to concrete actions2. Make Big ...

  4. Apache Spark源码走读之12 -- Hive on Spark运行环境搭建

    欢迎转载,转载请注明出处,徽沪一郎. 楔子 Hive是基于Hadoop的开源数据仓库工具,提供了类似于SQL的HiveQL语言,使得上层的数据分析人员不用知道太多MapReduce的知识就能对存储于H ...

  5. IDM 通过防火墙规则阻止激活验证

    1. 打开Windows防火墙 2. 高级设置-->出站规则-->新建规则 3. 添加IDM程序路径,阻止连接 4. 在属性中添加作用域,远程IP地址: DNS解析出IP:register ...

  6. JS实现HTML静态页传值的方法

    JS实现HTML静态页传值的方法 作者:前端开发-武方博 发布:2012-10-29 分类:javascript 阅读:8,735次     此处使用JS方式实现静态页之间值传递,其实很简单,废话不多 ...

  7. Yii源码阅读笔记(十四)

    Model类,集中整个应用的数据和业务逻辑——场景.属性和标签: /** * Returns a list of scenarios and the corresponding active attr ...

  8. XPath学习:parent,child

    XPath 是一门在 XML 文档中查找信息的语言.XPath 可用来在 XML 文档中对元素和属性进行遍历. XPath 是 W3C XSLT 标准的主要元素,并且 XQuery 和 XPointe ...

  9. locations in main memory to be referenced by descriptive names rather than by numeric addresses

    Computer Science An Overview _J. Glenn Brookshear _11th Edition Chapter 6 Programming Languages As s ...

  10. P1092 虫食算 NOIP2002

    为了测试stl 30分的暴力写法... #include <bits/stdc++.h> using namespace std; const int maxn = 11; int n; ...