//-------------------------------------------------------------------
JNIEXPORT jint JNICALL Java_com_example_demo_record_ScreenShotService_getPicFromFrameBuffer
  (JNIEnv * env, jobject thiz, jint width, jint height, jint bit, jint filename){
	  LOGI("---进入到屏幕截图本地调用函数!---");

		fb_create();
		
		char cfilename[512];
		sprintf(cfilename, "/sdcard/luzhi/%d.bmp", filename);
		
		int i  = 0;
		if(bit == 0)
		{
			i = save_bmp(cfilename, width, height, g_fb.bits, g_fb.vi.bits_per_pixel);
		}
		else
		{
			i = save_bmp(cfilename, width, height, g_fb.bits, bit);
		}
		
		fb_destory(&g_fb);
		//(*env)->ReleaseStringUTFChars(filename, cfilename);
		
		if(i == 0)
		{
			LOGI("---生成文件失败!---");
			return -1;
		}
		LOGI("---生成文件成功!---");
		return 0;			
	}
int main(int argc, char **argv){
  clock_t t_ini, t_fin;
  double secs;

  t_ini = clock();
  bmp_info_header info;
  bmp_info_header info2;
  unsigned char *img;
  unsigned char *img2;

  //Imagenes del mismo tamaño
  img   = load_image("A.bmp", &info);
  img2  = load_image("B.bmp", &info2);

  printf("Mezclando...\n");
  mix(&info, &info2, img, img2);
  printf("Salvando...\n");
  save_bmp("test-mix.bmp", &info, img);
  printf("Grisando...\n");
  to_grayscale(&info, img);
  printf("Guardando resultado final...\n");
  save_bmp("test-grey.bmp", &info, img);

  free(img);
  free(img2);
  t_fin = clock();

  secs = (double)(t_fin - t_ini) / CLOCKS_PER_SEC;
  printf("%.16g milisegundos\n", secs * 1000.0);
  return 0;
}
예제 #3
0
void gen_thumbnail(const WCHAR *wsDir, const WCHAR *wsFile, const WCHAR *thumb_name){
	HBITMAP pThumbnail;
	HRESULT hr = CreateThumbnail(wsDir,wsFile,100,100,&pThumbnail);
	if( SUCCEEDED( hr ) ){
			save_bmp(thumb_name, pThumbnail);
	}
}
예제 #4
0
int main(const int argc, const char ** const argv)
{
    if (argc < 2) {
        printf("Usage: %s image.bmp\n", argv[0]);
        return 1;
    }
 
    static bitmap_info_header_t ih;
    const pixel_t *in_bitmap_data = load_bmp(argv[1], &ih);
    if (in_bitmap_data == NULL) {
        fprintf(stderr, "main: BMP image not loaded.\n");
        return 1;
    }
    printf("Info: %d x %d x %d\n", ih.width, ih.height, ih.bitspp);
 
    const pixel_t *out_bitmap_data =
        canny_edge_detection(in_bitmap_data, &ih, 45, 50, 1.0f);
    if (out_bitmap_data == NULL) {
        fprintf(stderr, "main: failed canny_edge_detection.\n");
        return 1;
    }
 
    if (save_bmp("out.bmp", &ih, out_bitmap_data)) {
        fprintf(stderr, "main: BMP image not saved.\n");
        return 1;
    }
 
    free((pixel_t*)in_bitmap_data);
    free((pixel_t*)out_bitmap_data);
    return 0;
}
예제 #5
0
int screen_shot(const char * path)
{
	struct FB * fb = NULL;
	fb = fb_create(1);
	if (fb) {
		save_bmp(path, fb_width(fb), fb_height(fb), fb_bits(fb), fb_bpp(fb));
		fb_destory(fb);
	}
	return 0;
}
예제 #6
0
void save_img(std::string filename, const Matrix<Color>& img)
{
    std::size_t n = filename.size();
    std::string extension3 = filename.substr(n-3, n);
    std::string extension4 = filename.substr(n-4, n);
    if(!extension3.compare("bmp"))
    {
        save_bmp(filename, img);
    }
    else if(!extension3.compare("gif"))
    {
        save_gif(filename, img);
    }
    else if(!extension3.compare("ico"))
    {
        save_ico(filename, img);
    }
    /*else if(!extension3.compare("jpg"))
    {
        save_jpeg(filename, img);
    }*/
    else if(!extension3.compare("pcx"))
    {
        save_pcx(filename, img);
    }
    else if(!extension3.compare("png"))
    {
        save_png(filename, img);
    }
    else if(!extension3.compare("pbm"))
    {
        save_pbm(filename, color2bwimage(img));
    }
    else if(!extension3.compare("pgm"))
    {
        save_pgm(filename, color2grayimage(img));
    }
    else if(!extension3.compare("ppm"))
    {
        save_ppm(filename, img);
    }
    else if(!extension3.compare("tga"))
    {
        save_tga(filename, img);
    }
    else if(!extension4.compare("tiff"))
    {
        save_tiff(filename, img);
    }
}
예제 #7
0
int screen_shot(const char * path)
{
	int w = 80;
	int h = 20;
	int size = w*h*2;
	char * buf = (char *)malloc(size + 10);
	
	if (buf) {
		memset(buf, 0xff, (size + 10));
		memset(buf, 0xff, size/2);
		memset(buf + size/2, 0x00, size/2);
		save_bmp("./jni/w.bmp", w, h, buf, 16);
		free(buf);
	}
	
	return 0;
}
예제 #8
0
파일: cmds.c 프로젝트: amcgregor/raven
void internal_screenshot(){
    // Dumps the screen to the files DJDOOM00.BMP, DJDOOM01.BMP, etc.
    byte fname[13];
    int i=0,got;

    // Skip through the files until we find a free one.
    do{
        sprintf(fname,"djdoom%02d.bmp",i);
        got=file_exists(fname,0,NULL);
        if(i==99){got=0;}
        if(got==0){
            save_bmp(fname,vgabuf,gamma_pal); // Take the actual screen shot.
            sprintf(saybuf,"wrote %s",fname); // Create ...
            con_printf(saybuf);               // ... and display console message.
        }
        i++;
    }while(got!=0);
}
예제 #9
0
파일: tofb.c 프로젝트: xingskycn/tofb
static int file_to_file(const char * srcpath, const char * dstpath, int output_rgb)
{
	int ret = -1;
	BMP_READ * bmp = NULL;
	int w, h;
	int srcbpp, dstbpp;
	void * pdata = NULL, * bmpdata = NULL;
	RGB_CONVERT_FUN convert_func = NULL;

	do 
	{
		bmp = bmp_open(srcpath);
		if (!bmp) {
			break;
		}
		
		w = bmp_width(bmp);
		h = bmp_height(bmp);
		bmpdata = bmp_data(bmp);
		srcbpp = bmp_bpp(bmp);
		dstbpp = g_rgbbpp[output_rgb];

		convert_func = get_convert_func(srcbpp, dstbpp);
		if (convert_func) {
			pdata = convert_func(bmpdata, w, h);
			bmpdata = pdata;
		}

		if (!bmp_forward(bmp)) {
			line_reversal(bmpdata, w, h, dstbpp);
		}
		
		ret = save_bmp(dstpath, w, h, bmpdata, dstbpp);
	} while (0);

	bmp_close(bmp);
	if (pdata) {
		free(pdata);
	}
	return ret;	
}
예제 #10
0
파일: tofb.c 프로젝트: xingskycn/tofb
static int fb_to_file(const char * dstpath, int output_rgb)
{
	int ret = -1;
	int w, h;
	int srcbpp, dstbpp;
	void * pdata = NULL, * fbdata = NULL;
	RGB_CONVERT_FUN convert_func = NULL;

	struct FB * fb = NULL;

	do 
	{
		fb = fb_create(1);
		if (!fb) {
			break;
		}

		w = fb_width(fb);
		h = fb_height(fb);
		fbdata = fb_bits(fb);
		srcbpp = fb_bpp(fb);
		dstbpp = g_rgbbpp[output_rgb];

		convert_func = get_convert_func(srcbpp, dstbpp);
		if (convert_func) {
			pdata = convert_func(fbdata, w, h);
			fbdata = pdata;
		}

		ret = save_bmp(dstpath, w, h, fbdata, dstbpp);
	} while (0);

	if (pdata) {
		free(pdata);
	}
	fb_destory(fb);
	
	return ret;
}
예제 #11
0
void menu(int value){
	printf("menu %d\n", value);
	if (value == 0) 
	{
		//glutDestroyWindow(win);
		//exit(0);
        SDLMOD_Event event;
        event.type = FF_QUIT_EVENT;
        event.user.data1 = NULL;
        SDLMOD_PushEvent(&event);
        printf("push FF_QUIT_EVENT\n");
	}
	else if (value == 7)
	{
		save_bmp();
	}
	else 
	{
		val = value;
	}
	glutPostRedisplay();
}
예제 #12
0
파일: demo.c 프로젝트: ST3ALth/TwoMbit-Core
int main( int argc, char** argv )
{
	image_t image;
	int sony_decoder = 0;
	int scrolling = 0;
	int x = 0;
	sms_ntsc_setup_t setup = sms_ntsc_composite;
	
	sms_ntsc_t* ntsc = (sms_ntsc_t*) malloc( sizeof (sms_ntsc_t) );
	if ( !ntsc )
		fatal_error( "Out of memory" );
	sms_ntsc_init( ntsc, &setup );
	
	load_bmp( &image, (argc > 1 ? argv [1] : "test.bmp"), 0 );
	image.height--; /* scrolling would read past end without this */
	init_window( SMS_NTSC_OUT_WIDTH( image.width ), image.height * 2 );
	
	while ( read_input() )
	{
		x = (x + scrolling) % image.width;
		
		lock_pixels();
		
		sms_ntsc_blit( ntsc, image.rgb_16 + x, image.row_width,
				image.width, image.height, output_pixels, output_pitch );
		
		double_output_height();
		display_output();
		
		switch ( key_pressed )
		{
			case ' ': scrolling = !scrolling; break;
			case 'c': setup = sms_ntsc_composite; break;
			case 's': setup = sms_ntsc_svideo; break;
			case 'r': setup = sms_ntsc_rgb; break;
			case 'm': setup = sms_ntsc_monochrome; break;
			case 'd': sony_decoder = !sony_decoder; break;
		}
		
		if ( key_pressed || mouse_moved )
		{
			/* available parameters: hue, saturation, contrast, brightness,
			sharpness, gamma, bleed, resolution, artifacts, fringing */
			setup.sharpness = mouse_x;
			setup.gamma     = mouse_y;
			
			setup.decoder_matrix = 0;
			if ( sony_decoder )
			{
				/* Sony CXA2025AS US */
				static float matrix [6] = { 1.630, 0.317, -0.378, -0.466, -1.089, 1.677 };
				setup.decoder_matrix = matrix;
			}
			
			sms_ntsc_init( ntsc, &setup );
		}
	}
	
	save_bmp( argc > 2 ? argv [2] : "filtered.bmp" );
	
	free( ntsc );
	
	return 0;
}
예제 #13
0
static int decode_thread(void *arg) {
    VideoState *is = (VideoState *)arg;
    AVFormatContext *ic = NULL;
    AVPacket pkt1, *packet = &pkt1;
    int ret, i;
	int video_index = -1;

	is->videoStream = -1;

    global_video_state = is;
    if (avformat_open_input(&ic, is->filename, NULL, NULL) != 0) {
        return -1;
    }

    /* 这个回调函数将赋值给AVFormatContex,这样当读取流出现问题的时候会调用我们的自己的处理 */
	static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
	ic->interrupt_callback = int_cb;

    is->ic = ic;
	is->external_clock_base = 0;
	is->external_clock_base = get_external_clock(is);

    if (avformat_find_stream_info(ic, NULL) < 0) {
        return -1;
    }

    av_dump_format(ic, 0, is->filename, 0);

    for(i=0; i<ic->nb_streams; i++) {
		if(ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_index < 0)
			video_index = i;
    }
	
	if(video_index >= 0) stream_component_open(is, video_index); 

    /* 开始解码主循环 */
    for(;;) {
        if(is->quit) 
		  break;
		/* 这里处理视频的快进和快退 */
		if(is->seek_req) {
			int stream_index = -1;
			int64_t seek_target = is->seek_pos;

			is->external_clock_base = 0;
			is->external_clock_base = get_external_clock(is) - (seek_target / 1000000.0);
			
			if(is->videoStream >= 0) 
			  stream_index = is->videoStream;
		
			/* av_rescale_q(a, b, c):通过计算a*b/c来把一个时间基调整到另一个时间基 */
			/* 使用这个函数的原因是可以防止计算溢出,AV_TIME_BASE_Q是AV_TIME_BASE作*/
			/* 为分母的版本                                                        */
			if(stream_index >= 0) 
				seek_target = av_rescale_q(seek_target, AV_TIME_BASE_Q , ic->streams[stream_index]->time_base);

			if(av_seek_frame(is->ic, stream_index, seek_target, is->seek_flags) < 0) {
				fprintf(stderr, "%d: %s error seek\n", __LINE__, is->filename);
			} else {
				/* 跳转后需要清空我们自己的缓冲队列和avcodec内部缓冲*/
				/* 然后放入一个用来标识刷新队列的标志包             */
				if(is->videoStream >= 0) {
					packet_queue_flush(&is->videoq);
					packet_queue_put(&is->videoq, &flush_pkt);
				}
			}

			is->seek_req = 0;
		}
		//printf("decode_thread loop check videoq size %d\n", is->videoq.size);
        if (is->videoq.size > MAX_VIDEOQ_SIZE) {
			//printf("decode_thread loop delay %d\n", is->videoq.size);
            SDLMOD_Delay(10);
            continue;
        }

        ret = av_read_frame(is->ic, packet);
        if (ret < 0) {
            if(ret == AVERROR_EOF || url_feof(is->ic->pb)) {
                break;
            }
            if(is->ic->pb && is->ic->pb->error) {
                break;
            }
            continue;
        }

		if(packet->stream_index == is->videoStream) {
			packet_queue_put(&is->videoq, packet);
        } else {
            av_free_packet(packet);
        }
        //printf("decode_thread loop %d\n", is->videoq.size);
    }

	printf("decode_thread loop wait start\n");
	save_bmp();
    while (!is->quit && is->videoq.size > 0) {
        //printf("decode_thread delay %d\n", is->videoq.size);
        SDLMOD_Delay(100);
    }

fail: {
        SDLMOD_Event event;
        event.type = FF_QUIT_EVENT;
        event.user.data1 = is;
        SDLMOD_PushEvent(&event);
        printf("push FF_QUIT_EVENT\n");
    }

    return 0;
}
int32_t main(){
	save_bmp("output.bmp");

	return 0;
	
}
예제 #15
0
파일: rleori.c 프로젝트: Li2012/palresearch
int main(int argc,char* argv[])
{	
	int map=0,pat=0,mapgroup=0;
	int maps=-1,pats,mapgroups,pmaps;
	int mapchg=1,patchg=1,mapgroupchg=1;
	int width[0x200],height[0x200];
	int px,py,pw,ph;
	int rle0,data,i,j,t;
	int running=1;
	int len=0,s;
	int max;
	int vx[0x200],vy[0x200];
	char filename[12];
	char tosay[100];
	byte *buf=(byte*)malloc(0x12000),
	     *here;
	
	static BITMAP *bmp[0x200];
	BITMAP *tb;;
	PALETTE pal;
	
	FILE* fp=fopen(argv[1],"rb");
	FILE* fppat=fopen("pat.mkf","rb");
	
	if((fp==NULL)||(fppat==NULL))
	{
		printf("Usage:rle *.mkf");
		exit(-1);
	}
	
	//*(strrchr(argv[1],'.'))='\0';
	
	mapgroups=fget32(fp)/4-2,pats=fget32(fppat)/4-2;
	
	allegro_init();
	set_gfx_mode(GFX_AUTODETECT_WINDOWED,320,200,0,0);
	install_keyboard();
	atexit(allegro_exit);


	tb=create_bitmap(320,200);
	clear(tb);

	while(running)
	{		
		if(mapgroupchg)
		{	
			seekmkf(fp,mapgroup);s=ftell(fp);
			seekmkf(fp,mapgroup+1);len=ftell(fp)-s;
			if(len==0)
			{
				mapgroupchg=mapchg=1;
				map=0;
				mapgroup++;
				continue;
			}
			else
			{
				fseek(fp,s,SEEK_SET);
				fread(buf,len,1,fp);
				max=*(int*)(buf+4);
				deyj1(&buf);
				pmaps=maps;
				maps=(*(short*)(buf))-1;
				map=0;
				mapchg=1;
				mapgroupchg=0;
				for(j=0;j<=maps;j++)
				{
					if((here=seeksub(buf,j,max))==NULL)
					{
						maps=j-1;break;
					}
					width[j]=*(short*)(here),height[j]=*(short*)(here+2);
					vx[j]=(320-width[j])/2,vy[j]=(200-height[j])/2;
					here+=4;
					if(j<=pmaps) destroy_bitmap(bmp[j]);
					bmp[j]=create_bitmap(width[j],height[j]);
					for(i=0;i<width[j]*height[j];)
					{
						data=*here++;
						rle0=data>0x80?1:0;
						t=i;
						if(rle0)
							for(;i<t+data-0x80;i++)
								putpixel(bmp[j],i%width[j],i/width[j],0);
						else
							for(;i<t+data;i++)
								putpixel(bmp[j],i%width[j],i/width[j],*here++);
					}
				}
				blit(tb,screen,0,0,0,0,320,200);
			}
		}
		
		//change a palette
		if(patchg)
		{
			seekmkf(fppat,pat);
			for(i=0;i<256;i++)
			{	pal[i].r=fget8(fppat);
				pal[i].g=fget8(fppat);
				pal[i].b=fget8(fppat);
			}
			set_palette(pal);
			patchg=0;
		}		
		
		//render a frame
		if(mapchg)
		{
			if((vx[map]>px)||(vy[map]>py)||(width[map]<pw)||(height[map]<ph))
				blit(tb,screen,0,0,0,0,320,200);
			px=vx[map],py=vy[map],pw=width[map],ph=height[map];
			blit(bmp[map], screen, 0, 0, px, py, pw, ph);
			mapchg=0;
		}
		
		textprintf(screen,font,0,0,0xFF,"group:%x,id:%x,pat:%x",mapgroup,map,pat);			

		//Event handling
		while(!keypressed())	rest(100000);
		switch(readkey()>>8) {
		case KEY_DOWN:
			map=(map+1)%(maps+1);
			mapchg=1;
			if(!map)	
				blit(tb,screen,0,0,0,0,320,200);
			break;
		case KEY_RIGHT:
			pat=(pat+1>pats)?pat:pat+1;
			patchg=1;
			break;
		case KEY_PGDN:
			mapgroup=(mapgroup+1>mapgroups)?mapgroup:mapgroup+1;
			mapgroupchg=1;
			break;
		case KEY_UP:
			map=(map-1<0)?maps:map-1;
			mapchg=1;
			break;
		case KEY_LEFT:
			pat=(pat-1<0)?0:pat-1;
			patchg=1;
			break;
		case KEY_PGUP:
			mapgroup=(mapgroup-1<0)?mapgroup:mapgroup-1;
			mapgroupchg=1;
			break;
		case KEY_ESC:
			running=0;
			break;
		case KEY_S:
			sprintf(filename,"%s-%d-%d.bmp",argv[1],mapgroup,map);
			save_bmp(filename,bmp[map],pal);
			break;
		}
	}
	//finalize
	destroy_bitmap(tb);
	for(i=0;i<maps;i++)
		destroy_bitmap(bmp[i]);
	fclose(fp);fclose(fppat);
	free(buf);
	return 0;
}
예제 #16
0
int main(int argc, char *argv[]) {
	double			pos;
    VideoState      *is;


    if(argc < 2) {
        fprintf(stderr, "Usage: test <file>\n");
        exit(1);
    }

#ifdef __MINGW32__
	ptw32_processInitialize();
	//ptw32_processTerminate();
#endif

	//XInitThreads();

    is = (VideoState *)av_mallocz(sizeof(VideoState));

	avcodec_register_all();
	//avdevice_register_all();
	avfilter_register_all();
    av_register_all();
	avformat_network_init();

	if (USE_EVENT_MULTI_THREAD)
	{
		if ( SDLMOD_StartEventLoop(SDLMOD_INIT_EVENTTHREAD) < 0 ) {
			fprintf(stderr, "Could not start SDLMOD event loop (multi thread)\n");
			exit(1);
		}
	}
	else
	{
		if ( SDLMOD_StartEventLoop(0) < 0 ) {
			fprintf(stderr, "Could not start SDLMOD event loop (main thread)\n");
			exit(1);
		}
	}
	if (SDLMOD_TimerInit() != 0)
	{
		fprintf(stderr, "SDLMOD_TimerInit failed\n");
		exit(1);
	}

	g_video_width = 640;
	g_video_height = 480;
	g_video_resized = 0;

	//screen = SDL_SetVideoMode(g_video_width, g_video_height, SDL_VIDEO_MODE_BPP, SDL_VIDEO_MODE_FLAGS);
	screen = SDLMOD_CreateRGBSurface(0,
		g_video_width, g_video_height, SDL_VIDEO_MODE_BPP,
		Rmask, Gmask, Bmask, Amask
		);
	if(!screen) {
		fprintf(stderr, "SDL: could not set video mode - exiting\n");
		exit(1);
	}

    screen_mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
    pthread_mutex_init(screen_mutex, NULL);

    av_strlcpy(is->filename, argv[1], sizeof(is->filename));

	is->pictq_mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
    pthread_mutex_init(is->pictq_mutex, NULL);
    is->pictq_cond = (pthread_cond_t *)malloc(sizeof(pthread_cond_t));
    pthread_cond_init(is->pictq_cond, NULL);
    
	schedule_refresh(is, 40);

	is->av_sync_type = AV_SYNC_VIDEO_MASTER;

    {
		int err;
		is->parse_tid = (pthread_t *)malloc(sizeof(pthread_t));
		err = pthread_create(is->parse_tid, NULL, decodeThread, is);
		if (err!=0)
		{
			free(is->parse_tid);
			printf("can't create thread: %s\n", strerror(err));
			exit(0);
		}
	}
    if (!is->parse_tid) {
        av_free(is);
        return -1;
    }

	av_init_packet(&flush_pkt);
	flush_pkt.data = (uint8_t*)"FLUSH";

#if USE_EVENT_LOOP_MT
	{
		pthread_t pid;
		pthread_create(&pid, NULL, event_loop, is);
		if (0)
		{
			pthread_join(pid, NULL);
		}
		else
		{
#if USE_GL
			glutInit(&argc, argv);
			glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
			glutInitWindowSize(g_video_width, g_video_height);
			glutInitWindowPosition(0, 0);
			
			win = glutCreateWindow(TITLE);
			createMenu();

			glutDisplayFunc(display);
			glutReshapeFunc(reshape);
			glutMouseFunc(mouse);
			glutMotionFunc(motion);
			glutIdleFunc(idle);

			if (initEnvironment())
			{
				glutMainLoop();
			}
#else
			printf(">>>>>>Please input command (exit, quit, save):<<<<<<\n");
			char string[256];
			char* ret;
			while(1)
			{
				ret = gets(string);
				if (strcmp(string, "exit") == 0 || 
				    strcmp(string, "quit") == 0 ||
				    strcmp(string, "e") == 0 ||
				    strcmp(string, "q") == 0
				    )
				{
					break;
				}
				else if (strcmp(string, "save") == 0 ||
					strcmp(string, "s") == 0
				    )
				{
					save_bmp();
					printf("save_bmp() finish.\n");
				}
				else
				{
					printf("Please input command (exit, quit, save):\n");
				}
			}
#endif
		}
	}
#else
	event_loop(is);
#endif

    return 0;
}
예제 #17
0
void SaveScreenshot(void)
{
	save_bmp("ss.bmp", buffer, NULL);
	rest(1000);
}