Write to 16 bit BufferedImage TYPE_USHORT_GRAY

前端 未结 3 1453
庸人自扰
庸人自扰 2021-01-06 18:29

I\'m trying to write 16 bit grayscale imagedata to a png using BufferedImage.TYPE_USHORT_GRAY. Normally I write to an image like so:

BufferedImage image = ne         


        
3条回答
  •  一个人的身影
    2021-01-06 19:14

    You probably need to widen the signed 16bit shorts to ints and remove the sign:

    int ushort = (int)(shortData[x][y]) & 0xFFFF;
    

提交回复
热议问题