现在的位置: 首页 > 综合 > 正文

CIF格式文件转BMP文件

2013年06月06日 ⁄ 综合 ⁄ 共 954字 ⁄ 字号 评论关闭

笔者注:CIF文件内存放的是352*288真彩色数据

  1. #include <stdio.h>  
  2. #include <stdlib.h>  
  3.   
  4. #define WIDTH 352  
  5. #define HEIGHT 288  
  6.   
  7. //转换矩阵  
  8. double YuvToRgb[3][3] = {1,   0      ,  1.4022   ,  
  9.                          1,   -0.3456,   -0.7145 ,  
  10.                          1,   1.771  ,   0       };  
  11.   
  12. //根据RGB三分量写BMP,不必关注  
  13. int WriteBmp(int width, int height, unsigned char *R,unsigned char *G,unsigned char *B, char *BmpFileName);  
  14.   
  15. //转换函数  
  16. int Convert(char *file, int width, int height, int n)  
  17. {  
  18.     //变量声明  
  19.     int i = 0;  
  20.     int temp = 0;  
  21.     int x = 0;  
  22.     int y = 0;  
  23.     int fReadSize = 0;  
  24.     int ImgSize = width*height;  
  25.     FILE *fp = NULL;  
  26.     unsigned char* yuv = NULL;  
  27.     unsigned char* rgb = NULL;  
  28.     unsigned char* cTemp[6];  
  29.     char BmpFileName[256];  
  30.   
  31.     //申请空间  
  32.     int FrameSize = ImgSize + (ImgSize >> 1);  
  33.     yuv = (unsigned char *)malloc(FrameSize);  
  34.     rgb = (unsigned char *)malloc(ImgSize*3);  
  35.     //读取指定文件中的指定帧  

抱歉!评论已关闭.