项目场景:
BGRP转RGB24
BGRP:bbbbbbbbggggggrrrrrrr
RGB24:rgbrgbrgbrgbrgbrgb
#include <stdio.h>
#include <stdlib.h>
unsigned char g_blue[640*640];
unsigned char g_green[640*640];
unsigned char g_red[640*640];
int main(int argc, char *argv[])
{
FILE *ifp,*ofp;
int i;
ifp = fopen("raw_640x640_bgrp.rgb","rb");
if (!ifp)
{
fprintf(stderr,"Can't open input file\n");
return 0;
}
ofp = fopen("cooked_640x640_rgb.rgb","wb");
if (!ofp)
{
fprintf(stderr,"Can't create output file\n");
return 0;
}
/* Read the Blue plane */
fread(g_blue,1,640*640,ifp);
/* Read the Green plane */
fread(g_green,1,640*640,ifp);
/* Read the Red plane */
fread(g_red,1, 640*640, ifp);
for (i = 0; i < 640*640; i++)
{
/* red */
fwrite(&g_red[i],1,1,ofp);
/* green */
fwrite(&g_green[i],1,1,ofp);
/* blue */
fwrite(&g_blue[i],1,1,ofp);
}
fclose(ifp);
fclose(ofp);
return 0;
}