Drawing on a 16-bit grayscale bitmap in memory

You need to draw a 16-bit grayscale bitmap. Linking a TCanvas to a bitmap would be wonderful. I use Delphi, but any language is fine. I just need an idea.

Any idea?

Converting grayscale to RGB is not an option since half the resolution (pixel depth) is lost in this process.

+7
source share
2 answers

You can try an image library, such as ImageFX, or for open source, try Graphics32 or VampyreImagingLIbrary , according to its Docs here it supports some operations, such as drawing lines and rectangles over an image loaded into the clipboard. I would expect scanner (image processing) libraries to support grayscale images better than imageless libraries, but I do not expect scanner image processing libraries to be memory-based.

But if you want to do the work directly in the visible buffer (you mention TCanvas), and you are ready to limit yourself only to Delphi XE and Windows 7, you can use the Direct2D context, which supports 16 and 32-bit depth, but since 32-bit color depth it will still be only 8-bit depth relative to the image in grayscale, I think that all ordinary graphic libraries without shades of gray will lose information about you.

If you do not mind using something a little old and a bit tied to Microsoft Windows, you can examine it using the DirectDraw-style (now it is integrated with DirectX ) to perform buffer management (hold 16-bit data) and let you draw it . I do not know that it has special support for 16-bit grayscale images.

Interestingly, WPF supports 16-bit shade of gray. If you could find out how they do it, you can use the technique in Delphi. This link also discusses the use of OpenGL for 16x brightness, but there is no suggestion that OpenGL allows this. I found people trying to use OpenGL for medical applications written in delphi (16-bit shade of gray), but did not refer to changing the image to memory.

+1
source

You can use Gdi + it will not work with a 16-bit shade of gray, but it works with a 48-bit RGB image.

therefore, we can convert 16-bit data to 48-bit RGB data by copying the same 16 bit in all three channels. Performs some drawing and then converts 48 bits back to 16 bits again

0
source

All Articles