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 BMP Info;
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;
BMP info. bmiheader. bisize = sizeof (bitmapinfoheader );
BMP info. bmiheader. biwidth = width;
BMP info. bmiheader. biheight = height;
BMP info. bmiheader. biplanes = 1;
BMP info. bmiheader. bibitcount = BPP;
BMP info. bmiheader. bicompression = bi_rgb;
BMP info. bmiheader. bisizeimage = 0;
BMP info. bmiheader. bixpelspermeter = 100;
Bminfo. bmiheader. biypelspermeter = 100;
BMP info. bmiheader. biclrused = 0;
BMP info. bmiheader. biclrimportant = 0;
Fwrite (& bmpheader, sizeof (bitmapfileheader), 1, FP );
Fwrite (& BMP info. bmiheader, sizeof (bitmapinfoheader), 1, FP );
Fwrite (prgbbuffer, width * height * BPP/8, 1, FP );
Fclose (FP );
Fp = NULL;
Return true;
}
1st answers to this question:
BMP info. bmiheader. biheight =-height;
2nd answers to this question:
The upside down is right, while the BMP image data goes from bottom to top.