Converting from signed char to unsigned char and back again?

后端 未结 5 890
清酒与你
清酒与你 2020-11-28 19:22

I\'m working with JNI and have an array of type jbyte, where jbyte is represented as an signed char i.e. ranging from -128 to 127. The jbytes represent image pixels. For ima

5条回答
  •  遥遥无期
    2020-11-28 19:50

    Do you realize, that CLAMP255 returns 0 for v < 0 and 255 for v >= 0?
    IMHO, CLAMP255 should be defined as:

    #define CLAMP255(v) (v > 255 ? 255 : (v < 0 ? 0 : v))
    

    Difference: If v is not greater than 255 and not less than 0: return v instead of 255

提交回复
热议问题