大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
void SaveBMP ( BYTE* data, int w, int h ) // data指代的是解码后的原始数据,格式为:NV12
{
FILE *f;
unsigned char *img = NULL;
int filesize = 54 + 3*w*h; //w is your image width, h is image height, both int
if( img ) { free( img ); }
img = (unsigned char *)malloc(3*w*h);
memset(img,0,sizeof(img));
for(int j=0; j<h; j++)
{
for(int i=0; i<w; i++)
{
unsigned char r,g,b;
r = data[(((j*w)+i)*4)+2];
g = data[(((j*w)+i)*4)+1];
b = data[(((j*w)+i)*4)+0];
img[(((j*w)+i)*3)+2] = (r);
img[(((j*w)+i)*3)+1] = (g);
img[(((j*w)+i)*3)+0] = (b);
}
}
unsigned char bmpfileheader[14] = {‘B’,’M’, 0,0,0,0, 0,0, 0,0, 54,0,0,0};
unsigned char bmpinfoheader[40] = {40,0,0,0, 0,0,0,0, 0,0,0,0, 1,0, 24,0};
unsigned char bmppad[3] = {0,0,0};
bmpfileheader[ 2] = (unsigned char)(filesize );
bmpfileheader[ 3] = (unsigned char)(filesize>> 8);
bmpfileheader[ 4] = (unsigned char)(filesize>>16);
bmpfileheader[ 5] = (unsigned char)(filesize>>24);
bmpinfoheader[ 4] = (unsigned char)( w );
bmpinfoheader[ 5] = (unsigned char)( w>> 8);
bmpinfoheader[ 6] = (unsigned char)( w>>16);
bmpinfoheader[ 7] = (unsigned char)( w>>24);
bmpinfoheader[ 8] = (unsigned char)( h );
bmpinfoheader[ 9] = (unsigned char)( h>> 8);
bmpinfoheader[10] = (unsigned char)( h>>16);
bmpinfoheader[11] = (unsigned char)( h>>24);
g_FrameCapFile[] = “framecap.bmp”; //保存的图片名称
f = fopen(g_FrameCapFile,”wb”);
fwrite(bmpfileheader,1,14,f);
fwrite(bmpinfoheader,1,40,f);
for(int i=0; i<h; i++)
{
fwrite(img+(w*(h-i-1)*3),3,w,f);
fwrite(bmppad,1,(4-(w*3)%4)%4,f);
}
fclose(f);
printf(“saved frame capture file width = %d, height = %d\n”, w, h);
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/189727.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...