[英]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.