SoFunction
Updated on 2025-03-11

Ideas and code for implementing window screenshots in Android emulator


void zjin_fb_update(void* context,
int w, int h, int ydir,
int format, int type,
unsigned char* pixels)
{
#define CHANNEL 4
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
int width = w;
int height = h;
FILE *file = fopen("", "wb");
if( file!=NULL )
{
memset( &bf, 0, sizeof( bf ) );
memset( &bi, 0, sizeof( bi ) );
= 'MB';//BM?
= sizeof(bf)+sizeof(bi)+width*height*CHANNEL;
= sizeof(bf)+sizeof(bi);
= sizeof(bi);
= width;
= height;
= 1;
= 8 * CHANNEL;
= width*height*CHANNEL;
fwrite( &bf, sizeof(bf), 1, file );
fwrite( &bi, sizeof(bi), 1, file );
fwrite( pixels, sizeof(unsigned char), height*width*CHANNEL, file );
fclose( file );
}
return;
}