反转黑白TIFF图像
2009-08-26 16:15
190 查看
将单色(黑白)TIFF图像进行颜色反转处理,即将黑色处理成白色,白色处理成黑色。参考了网上使用指针处理Bitmap的方法!
void ReverseTIFF(string sourceFilName, string destFileName) { Bitmap sourBitmap = (Bitmap)Image.FromFile(sourceFilName); Bitmap destBitmap = new Bitmap(sourBitmap.Width, sourBitmap.Height, PixelFormat.Format1bppIndexed); BitmapData sourData = sourBitmap.LockBits(new Rectangle(0, 0, sourBitmap.Width, sourBitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed); BitmapData destData = destBitmap.LockBits(new Rectangle(0, 0, sourBitmap.Width, sourBitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format1bppIndexed); unsafe { for (int y = 0; y < sourData.Height; y++) { byte* dataIn = (byte*)sourData.Scan0 + (y * sourData.Stride); byte* dataOut = (byte*)destData.Scan0 + (y * destData.Stride); for (int x = 0; x < sourData.Width / 8; x++) { dataOut[x] = (byte)(~dataIn[x]); } } } sourBitmap.UnlockBits(sourData); destBitmap.UnlockBits(destData); destBitmap.Save(destFileName); sourBitmap.Dispose(); destBitmap.Dispose(); return; }
相关文章推荐
- 压缩BMP图像为1像素的黑白图TIFF
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
- C# (GDI+相关) 图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果) (转)
- 黑白图像的图像增强
- 在Android上实现图像颜色过滤与反转
- noj-1102-黑白图像
- 【文件格式-TIFF】TIFF图像格式结构
- NOJ1102 黑白图像
- 图像滤镜处理算法:灰度、黑白、底片、浮雕
- TIFF图像数据的排列方式的装换
- 黑白图像
- OpenCv2.4.4实现反转(reverse)图像
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
- 图像处理(黑白,模糊,浮雕,圆角,镜像,底片,油画,灰白,加旧,哈哈镜,放大镜)
- [GDI+]如何将一个彩色图像转换成黑白图像
- NOJ1102黑白图像——深度搜索DFS
- [机器学习实战] 深度学习为黑白图像着彩色
- C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)
- 基于opencv的相机之图像保存异常/模糊背景/黑白背景(四)
- TIFF图像文件格式详解