在内存中绘制 16 位灰度位图
需要在内存中绘制 16 位灰度位图。将 TCanvas
与位图关联起来会很棒。我使用 Delphi,但任何语言都可以。我只需要这个想法。
有什么想法吗?
将灰度转换为 RGB 不是一种选择,因为在此过程中会丢失一半的分辨率(像素深度)。
In need to draw on a 16 bit greyscale in-memory bitmap. Associating a TCanvas
to the bitmap would be marvelous. I use Delphi but any language is OK. I just need the idea.
Any Idea ?
Converting the greyscale to RGB is not an option because half the resolution (pixel depth) is lost in the process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试像 ImageFX 这样的图像库,或者对于开源图像库,请尝试 Graphics32,或者 < a href="http://imaginglib.sourceforge.net/index.php?page=down" rel="nofollow noreferrer">VampyreImagingLIbrary,根据其文档 此处 它支持一些操作,例如在加载到缓冲区的图像上绘制线条和矩形。我希望扫描仪(图像处理)库比非成像库更好地支持灰度图像,但我不希望扫描仪图像处理库基于内存。
但是,如果您想直接在可见缓冲区中完成工作(您提到了 TCanvas),并且您愿意将自己限制在 Delphi XE 和 Windows 7 上,那么您可以使用 Direct2D 上下文,它支持 16 和 32 位深度但由于 32 位颜色深度相对于灰度图像而言仍然只有 8 位深度,我认为所有正常的非灰度图形库都会丢失一些有关您的信息。
如果您不介意使用有点旧的东西,并且与 Microsoft Windows 有点相关,您可以研究使用 DirectDraw 样式(现已合并到 DirectX) 既可以进行缓冲区管理(保存 16 位数据),也可以让您在其上进行绘制。但我不知道它对 16 位灰度图像有任何特殊支持。
有趣的是,WPF 本身就支持 16 位灰度。如果您能了解他们是如何做到这一点的,您就可以在 Delphi 中模仿该技术。该链接还讨论了使用 OpenGL 来实现 16 位亮度,但问题中没有建议 OpenGL 允许这样做。我发现有人试图将 OpenGL 用于用 delphi 编写的医疗应用程序(16位灰度)图像显示,但没有参考修改内存中的图像。
You could try an imaging library like ImageFX, or for an open-source one, try Graphics32, or the VampyreImagingLIbrary, according to its Docs here it supports some operations like drawing lines and rectangles over an image loaded into a buffer. I would expect scanner (image processing) libraries to support grey-scale images better than non-imaging libraries, but I don't expect scanner image processing libraries to be in-memory based.
But if you wanted to do the work directly in a visible buffer (You mention TCanvas), and you you are willing to limit yourself to Delphi XE, and Windows 7 only, you could use a Direct2D context, which supports 16 and 32 bit depths but as a 32 bit color depth is still only going to be 8 bit depth with respect to a grayscale image, I think that all normal non-greyscale graphics libraries are going to lose some information on you.
If you didn't mind using something a bit old, and a bit tied to Microsoft Windows, you could investigate using DirectDraw style (now merged into DirectX) both to do the Buffer management (hold the 16 bit data) and letting you draw onto it, as well. I am not aware of it having any special support for 16 bit grayscale images though.
Interestingly, WPF has support for 16 bit grayscale natively. If you could find out how they do it, you could ape the technique in Delphi. That link also discusses using OpenGL to do 16 bit luminance, but there's no suggestion from the question that OpenGL allows that. I have found people trying to use OpenGL for medical applications written in delphi (16 bit grayscale) image display, but no reference to modifying the image in memory.
你可以使用Gdi+
它不适用于 16 位灰度图像,但适用于 48 位 RGB 图像。
因此,我们可以通过在所有三个通道中复制相同的 16 位数据,将 16 位数据转换为 48 位 RGB 数据。执行一些绘图,然后再次将 48 位转换回 16 位
You can use Gdi+
it will not work on 16 bit grayscale but it does work on 48 bit RGB image.
so we can convert 16 bit data to 48 bit RGB data by copying the same 16 bit in all the three channels.performs some drawing and then again convert 48 bit back to 16 bit