[英]After byte shifitng a int to 4 bytes, how can I shift back to int (C)
所以我将一个整数字节移位到4个字节的数据中。
img[4] = (imagewidth >> 24) & 0xFF;
img[5] = (imagewidth >> 16) & 0xFF;
img[6] = (imagewidth >> 8) & 0xFF;
img[7] = imagewidth & 0xFF;
img[8] = (imageheight >> 24) & 0xFF;
img[9] = (imageheight >> 16) & 0xFF;
img[10] = (imageheight >> 8) & 0xFF;
img[11] = imageheight & 0xFF;
现在我将如何将其转换回整数。 所以img[8]
- img[11]
回到单个int
或img[4]
- img[7]
回到单个int
imagewidth = img[4] << 24 | img[5] << 16 | img[6] << 8 | img[7];
imageheight = img[8] << 24 | img[9] << 16 | img[10] << 8 | img[11];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.