C#读写BitMap及颜色相乘
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及颜色相乘的更多相关文章
- Bitmap 图片格式并用 C++ 读写 Bitmap
转自 Bitmap 图片格式并用 C++ 读写 Bitmap 1.Bitmap 图片格式 每部分的具体内容就不展开了.要说的有两点: (1)调色板不是必须的,可有可无,有没有调色板可以通过位图文件头的 ...
- 如何使用Palette提取Bitmap的颜色
5.X提出了color palette 的概念,能够让主题动态的去适应当前的页面色调,让整个app色调看起来比较和谐统一 那么如何使用Palette呢,必不可少,我们需要在Android studio ...
- directX学习系列8 颜色融合(转)
1, Multipass(多通道) 将一个任务划分成几个阶段,由多个pass处理不同阶段,后续pass总是处理前一个pass的结果.例如复杂的光照方程可以分成几个pass来计算. 用不同的 ...
- SharpDX之Direct2D教程I——简单示例和Color(颜色)
研究Direct2D已经有一段时间了,也写了一个系列的文章 Direct2D ,是基于Windows API Code Pack 1.1.在前文 Direct2D教程VIII——几何(Geometry ...
- OpenGL — GLFW — 颜色
OpenGL - GLFW - 颜色 参考教程:https://learnopengl-cn.readthedocs.io/zh/latest/02%20Lighting/01%20Colors/ 既 ...
- OpenGL光照1:颜色和基础光照
本文是个人学习记录,学习建议看教程 https://learnopengl-cn.github.io/ 非常感谢原作者JoeyDeVries和多为中文翻译者提供的优质教程 的内容为插入注释,可以先跳过 ...
- Shader 中的颜色计算
下面介绍 Shader 中 gl_FragColor 的计算与转换: 一.颜色计算 1. 加 这里要讲讲三原色和三基色:三原色一般指的是红.绿.蓝三种,简称 RGB,这是加色系.就是光源只含有特定的波 ...
- 一个使用openGL渲染的炫丽Android动画库
android-magic-surface-view 这是一个 android 动画特效库, 可以实现各种炫酷动画. github地址: https://github.com/gplibs/andro ...
- ImageLoader 笔记
BitmapFactory 我们不能够通过构造函数创建Bitmap对象.如果需要将图片转成Bitmap对象加载到内存中,就需要使用BitmapFactory类.BitmapFactory跟据图片数据源 ...
随机推荐
- 小组项目beta发布的评价
这次最看好飞天小女警组,相比上次他们的界面漂亮了很多,功能也相对完善,他们的礼物挑选系统非常有创意.如果去网上爬更多的数据,这个项目会更完美. 新蜂团队的俄罗斯方块游戏新增加了显示下一个方块以及游戏积 ...
- python twisted启动定时服务
以下是python脚本send_mms.py #############################################!/usr/bin/python# -*- coding: ut ...
- PHP file_get_contents函数读取远程数据超时的解决方法
PHP file_get_contents函数读取远程数据超时的解决方法 投稿:junjie 字体:[增加 减小] 类型:转载 这篇文章主要介绍了PHP file_get_contents函数读取 ...
- DirectX基础学习系列5 融合技术
7.1融合方程 1概念 融合技术将当前光栅化像素的颜色与以前已光栅化并处于同一个位置的像素颜色进行合成,即将当前要进行光栅化的三角形单元与已写入后台的像素进行融合 2需要遵循的原则: (1)先绘制不需 ...
- linux里的进程简介
/sbin/init 内核启动的第一个用户级进程,引导用户空间服务 [kthreadd] 内核线程管理[migration/0] 用于进程在不同的CPU ...
- Gender, Genre, and Writing Style in Formal Written Texts
http://u.cs.biu.ac.il/~koppel/papers/male-female-text-final.pdf Abstract. This paper explores di ...
- .Net程序员安卓学习之路1:登陆界面
任何编程学习起步均是HelloWorld,作为稍有>net编程经验的我们来说就跳过这步吧,咱们且从简单登录界面开始.先看看效果: 一.准备知识: 1. 安卓环境:安装好JDK,直接去官网下载AD ...
- Spring框架,如何返回数据给视图(jsp文件)
第一步 准备返回给视图的数据 package com.cwebs.samples; import java.util.LinkedHashMap; import java.util.List; imp ...
- xdebug和xhprof
在安装时出现不是:1% 不是有效的win32 应用程序原因可能是是下载了64位的.dll扩展与当前的php不兼容
- Introducing shard translator
Introducing shard translator by Krutika Dhananjay on December 23, 2015 GlusterFS-3.7.0 saw the relea ...