1.代码示例
#include
#include
#include
#include int main() {int width = 2592;int height = 1944;char *YUV = NULL;char *YUV_MIRROR = NULL;FILE *inFp = fopen("input.yuv", "rb");FILE *outMirror = fopen("ouput.yuv", "wb");YUV = new char[width*height*3/2];YUV_MIRROR = new char[width*height*3/2];//方式一:一次性全部读写文件//int count = fread(YUV, 1, size, inFp);//fwrite(YUV, 1, count, outMirror);////方式二:循环读文件,然后循环写int count = 0,step = 0;while((count = fread(YUV, 1, width, inFp) ) >0 ){fwrite(YUV, 1, count, outMirror);if(count < width)break;memset(YUV, 0, count); //bzero(YUV,0);step += count;//计算偏移量读写fseek(inFp, step, 0);}delete []YUV;delete []YUV_MIRROR;fclose(inFp);fclose(outMirror);return 0;
}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!