ffmpeg 轉 RGB 填充 bitmap

來源:互聯網
上載者:User
sws_scale( img_convert_ctx, 
          pVideoFrame[nChannel]->data, 
  pVideoFrame[nChannel]->linesize, 
                          0, 
  pCodeContext[nChannel]->height, 
  pRGBFrame->data, 
  pRGBFrame->linesize); 

CreateBmp(szFileName, pRGBFrame->data[0], 
            pCodeContext[nChannel]->width, 
pCodeContext[nChannel]->height, 
24) 

BOOL CreateBmp(char *filename, uint8_t *pRGBBuffer, int width, int height, int bpp) 

BITMAPFILEHEADER bmpheader; 
BITMAPINFO bmpinfo; 
FILE *fp = NULL; 

fp = fopen(filename,"wb"); 
if( fp == NULL ) 

return FALSE; 

bmpheader.bfType = ('M' < <8)|'B'; 
bmpheader.bfReserved1 = 0; 
bmpheader.bfReserved2 = 0; 
bmpheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); 
bmpheader.bfSize = bmpheader.bfOffBits + width*height*bpp/8; 

bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 
bmpinfo.bmiHeader.biWidth = width; 
bmpinfo.bmiHeader.biHeight = height; 
bmpinfo.bmiHeader.biPlanes = 1; 
bmpinfo.bmiHeader.biBitCount = bpp; 
bmpinfo.bmiHeader.biCompression = BI_RGB; 
bmpinfo.bmiHeader.biSizeImage = 0; 
bmpinfo.bmiHeader.biXPelsPerMeter = 100; 
bmpinfo.bmiHeader.biYPelsPerMeter = 100; 
bmpinfo.bmiHeader.biClrUsed = 0; 
bmpinfo.bmiHeader.biClrImportant = 0; 

fwrite(&bmpheader,sizeof(BITMAPFILEHEADER),1,fp); 
fwrite(&bmpinfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp); 
fwrite(pRGBBuffer,width*height*bpp/8,1,fp); 
fclose(fp); 
fp = NULL; 

return TRUE; 


這個問題第1個回答:
bmpinfo.bmiHeader.biHeight = -height;
這個問題第2個回答:
倒立才是對的,bmp的圖象資料是從下至上的 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.