I have an array of ushort pixel data that I need to save as a jpeg file. From what I’ve found I can do this by using
Image.Save(path, ImageFormat.Jpeg);
but I don’t know how to get the ushort data into the Image object. I’ve found ways to do this with byte arrays but not ushort.
I’ve spent far to much time trying to figure this out so now I ask the mighty StackOverflow, How do I this?
Edit:
Sorry, the ushorts are 16 bit grayscale values.
I think you have to actually create a
Bitmap, draw the pixels onto it and save it afterwards.Something like this:
Note that I don’t know how to get a 16 bit greyscale color information into the Color struct.