Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing on a 16 bit greyscale bitmap in memory

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.

like image 911
fpiette Avatar asked Jul 21 '11 17:07

fpiette


1 Answers

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.

like image 176
Warren P Avatar answered Oct 13 '22 19:10

Warren P