看了一些关于mipi格式的文章,不是图示错误,就是废话太多,不然就是代码辣眼睛。
raw14用7*8个byte表示4*14格式的像素
raw12用3*8个byte表示2*12格式的像素
raw10用5*8个byte表示4*10格式的像素
解析代码如下:
//raw14 b1,b2,b3,b4,b5,b6,b7分别为连续读出的七个uint8类型的数据,p1,p2,p3,p4为四个像素点的像素值,那么 for(int i=0;i<file_len;i+=7){ unsigned char* b = buffer + i; unsigned char b1 = b[0]; unsigned char b2 = b[1]; unsigned char b3 = b[2]; unsigned char b4 = b[3]; unsigned char b5 = b[4]; unsigned char b6 = b[5]; unsigned char b7 = b[6]; unsigned short p1 = (b1 << 6) | (b5 & 0x3f); unsigned short p2 = (b2 << 6) | (((b5 >> 6) & 0x3) << 4) | (b6 & 0xf); unsigned short p3 = (b3 << 6) | (((b6 >> 4) & 0xf) << 2) | (b7 & 0x3); unsigned short p4 = (b4 << 6) | ((b7 >> 2) & 0x3f); fwrite(&p1, 2, 1, fp2); fwrite(&p2, 2, 1, fp2); fwrite(&p3, 2, 1, fp2); fwrite(&p4, 2, 1, fp2); } //raw12 b1,b2,b3分别为连续读出的三个uint8类型的数据,p1,p2为两个个像素点的像素值,那么 for(int i=0;i<file_len;i+=3){ unsigned char* b = buffer + i; unsigned char b1 = b[0]; unsigned char b2 = b[1]; unsigned char b3 = b[2]; unsigned short p1 = (b1 << 4) | ((b3 ) & 0xf); unsigned short p2 = (b2 << 4) | ((b3 >> 4) & 0xf); //printf("%d,%d,%d,%d\n", p1, p2, p3, p4); fwrite(&p1, 2, 1, fp2); fwrite(&p2, 2, 1, fp2); } //raw10 b1,b2,b3,b4,b5分别为连续读出的五个uint8类型的数据,p1,p2,p3,p4为四个像素点的像素值,那么 for (int i=0;i<file_len;i+=5){ unsigned char*b = buffer + i; unsigned char b1 = b[0]; unsigned char b2 = b[1]; unsigned char b3 = b[2]; unsigned char b4 = b[3]; unsigned char b5 = b[4]; unsigned short p1 = (b1 << 2) | ((b5) & 0x3); unsigned short p2 = (b2 << 2) | ((b5 >> 2) & 0x3); unsigned short p3 = (b3 << 2) | ((b5 >> 4) & 0x3); unsigned short p4 = (b4 << 2) | ((b5 >> 6) & 0x3); //printf("%d,%d,%d,%d\n", p1, p2, p3, p4); fwrite(&p1, 2, 1, fp2); fwrite(&p2, 2, 1, fp2); fwrite(&p3, 2, 1, fp2); fwrite(&p4, 2, 1, fp2); }
标签:RAW10,p2,RAW12,MIPI,p4,p3,fwrite,p1,fp2 From: https://www.cnblogs.com/changweijinghu/p/18683251