Example #1
0
void ccd_capture_image() {

	if(!bmp_open("example24.bmp", &current_image)) {
		printf("ccd_capture_image(): failed to open file\n");
		exit(0);
	}
}
Example #2
0
File: oo_ui.c Project: EX311/moira
void set_bgimage(void)
{
	bmphandle_t bh;
	if (chat_count > 0 || no_count > 10)
		return;

	bh = bmp_open(bg_image);
	if (bh == NULL) {
		perror("bmp_open");
		clear_screen();	
		return;
	}

	if (bmp_width(bh) > 320 || bmp_height(bh) > 240) {
		clear_screen();
		fprintf(stderr, "bmp size is too large: %d x %d\n", bmp_width(bh), bmp_height(bh));
		bmp_close(bh);
		return;
	}

	buf_bmp(bh, 0, 0);
	bmp_close(bh);

	show_vfb(vfb_list[0]);
}
Example #3
0
static int file_to_fb(const char * srcpath)
{
	int ret = -1;
	BMP_READ * bmp = NULL;
	struct FB * fb = NULL;
	int sw, sh;
	int srcbpp, dstbpp;
	void * pdata = NULL, * bmpdata = NULL;
	RGB_CONVERT_FUN convert_func = NULL;
	
	do 
	{
		bmp = bmp_open(srcpath);
		if (!bmp) {
			break;
		}
		fb = fb_create(0);
		if (!fb) {
			break;
		}
		
		sw = bmp_width(bmp);
		sh = bmp_height(bmp);
		bmpdata = bmp_data(bmp);
		srcbpp = bmp_bpp(bmp);
		dstbpp = fb_bpp(fb);
		
		convert_func = get_convert_func(srcbpp, dstbpp);
		if (convert_func) {
			pdata = convert_func(bmpdata, sw, sh);
			bmpdata = pdata;
		}
		
		if (!bmp_forward(bmp)) {
			line_reversal(bmpdata, sw, sh, dstbpp);
		}
		
		rgb_copy(bmpdata, fb_bits(fb), sw, sh, fb_width(fb), fb_height(fb), dstbpp);
		ret = 0;
	} while (0);
	
	fb_destory(fb);
	bmp_close(bmp);
	if (pdata) {
		free(pdata);
	}
	return ret;	
}
Example #4
0
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;	
}
Example #5
0
File: oo_ui.c Project: EX311/moira
void draw_icon(struct icon *icon)
{
	int i, j;
	bmphandle_t bh;

	if (icon->mode) {
		bh = bmp_open(icon->name);
		if (bh == NULL) {
			perror("bmp_open");
			return;
		}
		for (i=icon->y; i<icon->y+bmp_height(bh); i++)
			for (j=icon->x; j<icon->x+bmp_width(bh); j++)
				*(myfb->fb + i*myfb->fbvar.xres +j) = makepixel(bmp_getpixel(bh, j-icon->x, i-icon->y));

		bmp_close(bh);
	} else {
		drow_rect(icon->x, icon->y, icon->x + icon->w, icon->y + icon->h, icon->color);
		put_string_center(icon->x + icon->w/2, icon->y + icon->h/2, icon->name, icon->color);
	}
}
Example #6
0
//for libgd2 < 2.99.999
gdImagePtr
gdImageCreateFromBmpPtr(int size, void *data)
{
	gdImagePtr ret;
	bmphandle_t bh;
	int h, w, i, j;
	struct bgrpixel r;
	int color;
	bh = bmp_open(data, size);
	if (bh == NULL)
		return NULL;
	h = bmp_height(bh);
	w = bmp_width(bh);
	ret = gdImageCreateTrueColor(w, h);
	for (i = 0; i < w; i++) {
		for (j = 0; j < h; j++) {
			r = bmp_getpixel(bh, i, j);
			color = gdImageColorResolve(ret, r.r, r.g, r.b);
			gdImageSetPixel(ret, i, j, color);
		}
	}
	bmp_close(bh);
	return ret;
}
Example #7
0
int main(int argc , char**argv)
{


	struct color color;

	int i, j;
	//char* fb_list[ VFB_MAX];

	int x,y;

	int master;

	ip_list[0] = "192.168.77.30";
	ip_list[1] = "192.168.77.55";

	int debug_send_data_size =0;
#if DEBUG
	int test_count =0 ;
#endif


	master = atoi(argv[1]);
	myfb = myfb_open();
	

	// is master ? yse -> client , no ->server
	
	//if (master == mylocation)
	if (master == 1)
	{
			
		if(argc !=5)
		{
			perror("useing filename (int)arg [master is 1, slaver 2");
			exit(1);
		}	
	
		set_vfb_buf(4);
		bh = bmp_open(argv[2]);
		buf_bmp(bh,atoi(argv[3]),atoi(argv[4]));

		

		client_sock = tcp_client_connect( ip_list[1], "8000") ;
/*		
	// show my location data [pixel]
		x= 150;
		y= 30;
	
	//	for ( x = 150; x < 200; x++)
		{
			printf(" test for loop 1 x= %d\n",x);
			for( i =0 ; i<50; i++)
			{

				for(j=0; j <400 ; j++)
					buf_pixel(vfb_list[0],j+x,i+y,color);
			}

			//show_vfb(vfb_list[mylocation]);
*/
			show_vfb(vfb_list[0]);  // my fb data show
			debug_send_data_size = send_data(vfb_list[1]);
			#if DEBUG
				printf("send_data() call %d , send data size is %d\n",test_count,debug_send_data_size);
				test_count++;
			#endif

	}

	

	else
	{
			do_server();
	}
	
	
	
	
/*
	drow_rect(10,10,150,60,color);
	drow_line(150,150, 300,200,color);

	color.r = 255 ;
	color.g = 0;
	color.b = 0 ;

	//fb_list = set_vfb_buf(2);
	set_vfb_buf(2);

	x= 10;
	y= 30;
	
	for (; x<200; x++)
	{

		for( i =0 ; i<50; i++)
		{
			for(j=0; j <200 ; j++)
				buf_pixel(vfb_list[0],j+x,i+y,color);
		}

		show_vfb(vfb_list[0]);
	}


	
	printf("x-resolution : %d\n", myfb->fbvar.xres);
	printf("y-resolution : %d\n", myfb->fbvar.yres);
	printf("x-resolution(virtual) : %d\n", myfb->fbvar.xres_virtual);
	printf("y-resolution(virtual) : %d\n", myfb->fbvar.yres_virtual);
	printf("bpp : %d\n", myfb->fbvar.bits_per_pixel);
	printf("smem_len: %d\n", myfb->fbfix.smem_len);
*/
	return 0; 
}