}
img_convert_ctx =
sws_getCachedContext(img_convert_ctx,pCodeCtx->width,pCodeCtx->height,
pCodeCtx->pix_fmt,pCodeCtx->width,pCodeCtx->height,PIX_FMT_RGB24,SWS_
if (img_convert_ctx == NULL) { }
//将YUV12转换为RGB24
sws_scale(img_convert_ctx, (const uint8_t*
char temp[10];
_itoa_s(num,temp,10);
char path[256] = \;
strcat_s(path,sizeof(path),temp); strcat_s(path,sizeof(path),fileEx); ++num;
pCodeCtx->height, pFrameRGB->data,pFrameRGB->linesize); abort();
BICUBIC,NULL,NULL,NULL);
const*)pFrame->data,pFrame->linesize, 0,
BMP_SaveFile(path,pFrameRGB->data[0],pCodeCtx->width,pCodeCtx->height }
//回收资源
av_free(buffer); av_free(pFrameRGB); av_free(pFrame);
avcodec_close(pCodeCtx);
avformat_close_input(&pFormatCtx); return 0;
}
av_free_packet(&pPacket);
}
,24);
bool BMP_SaveFile(const char* szFile, const void* pBmp, int width, int height, int bitCount)
{ }
void reverseChar(char**strs,int nSize) {
//定义一个指针指向strs的内存地址 char *p = *strs; char tmp;
for (unsigned int i = 0; i < nSize/2 ; i++) return true;
reverseChar((char **)&pBmp,bmp_size); fwrite(pBmp, bmp_size, 1, pFile); fclose(pFile);
BITMAPINFOHEADER bmiHeader;
bmiHeader.biSize = sizeof(bmiHeader); bmiHeader.biWidth = width; bmiHeader.biHeight = height; bmiHeader.biPlanes = 1; bmiHeader.biBitCount = bitCount; bmiHeader.biCompression = 0; bmiHeader.biSizeImage = bmp_size; bmiHeader.biXPelsPerMeter = 0; bmiHeader.biYPelsPerMeter = 0; bmiHeader.biClrUsed = 0; bmiHeader.biClrImportant = 0; fwrite(&bmiHeader, sizeof(bmiHeader), 1, pFile); BITMAPFILEHEADER bmpHeader;
bmpHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) bmpHeader.bfType = 0x4D42;
bmpHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + bmpHeader.bfReserved1 = 0; bmpHeader.bfReserved2 = 0;
fwrite(&bmpHeader, sizeof(bmpHeader), 1, pFile); int bmp_size = width*height*(bitCount/8); FILE* pFile = NULL;
fopen_s(&pFile,szFile, \); ASSERT(pFile != NULL);
+ bmp_size;
sizeof(BITMAPINFOHEADER);
}
{ }
tmp = *(p+i);
*(p+i) = *(p + nSize - 1 - i); *(p + nSize - 1 - i) = tmp;