.NET中的Format16bppGrayScale问题 [英] Problem with Format16bppGrayScale in .NET

查看:136
本文介绍了.NET中的Format16bppGrayScale问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何在.net中处理16位灰度图像考虑这两个简单的代码:

Any one have idea about how to handle 16 bit gray scale images in .net consider this two simple code:

Dim Bitmap As New Bitmap(100, 100)
       Dim BitmapData As BitmapData = Bitmap.LockBits(New Rectangle(0, 0, Bitmap.Width, Bitmap.Height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)



调试此代码时会发生此错误:



参数无效。



还有其他方法可以在.net中处理16位灰度图像吗?

请注意,我知道我可以使用48bpp代替它,但我考虑的是我的应用速度阳离子特别是在改变对比度/亮度时,对于3072 * 3072图像,改变对比度/亮度的过程约为0.7秒,很明显它不适合实时。请给出另一个解决方案。


when you debug this code this error will happen:

Parameter is not valid.

Is there any other way to handle 16 bit gray scale image in .net?
Attention please I know I can use 48bpp instead it but my consider in the speed of my application specially when change contrast/brightness, for a 3072*3072 image the process of changing contrast/brightness is around 0.7 second and it is clear that it is not suitable for real time. Please give another solution.

推荐答案

LockBits中的像素格式必须与要锁定的位图的格式兼容...一个简单的新的位图(w,h)没有其他参数会创建32位RGB图像,并且无法锁定为16位灰度!!!

使用也可以获得像素格式的构造函数变体: https:// msdn。 microsoft.com/en-us/library/3z132tat(v=vs.110).aspx [ ^ ]

The pixel format in LockBits must be compatible with the format of the bitmap you want to lock...A simple new Bitmap(w,h) with no additional parameters will create a 32 bit RGB image, and it can not be locked as 16 bit gray-scale!!!
Use the constructor variant that can get pixel format too: https://msdn.microsoft.com/en-us/library/3z132tat(v=vs.110).aspx[^]
Dim Bitmap As New Bitmap(100, 100, PixelFormat.Format16bppGrayScale)


这篇关于.NET中的Format16bppGrayScale问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆