示例#1
0
文件: image.c 项目: pd-l2ork/pd
static void image_imagesize_callback(t_image *x, t_float w, t_float h) {
	//fprintf(stderr,"received w %f h %f should %d spill %d\n", w, h, gobj_shouldvis((t_gobj *)x, glist_getcanvas(x->x_glist)), x->x_gop_spill);
	x->x_img_width = w;
	x->x_img_height = h;
	if (x->x_img_width + x->x_img_height == 0) {
		//invalid image
		if (strcmp("@pd_extra/ggee/empty_image.png", x->x_fname->s_name) != 0) {
			x->x_fname = gensym("@pd_extra/ggee/empty_image.png");
			image_doopen(x);
			return;
		}
	}
	if (!gobj_shouldvis((t_gobj *)x, x->x_glist) && !x->x_gop_spill) {
			//fprintf(stderr,"erasing\n");
			image_erase(x, glist_getcanvas(x->x_glist));
	} else {
		//sys_vgui("catch {.x%lx.c delete %xMT}\n", glist_getcanvas(x->x_glist), x);
		// reselect if we are on a toplevel canvas to adjust the selection rectangle, if necessary
		if (glist_isselected(x->x_glist, (t_gobj *)x) && glist_getcanvas(x->x_glist) == x->x_glist) {
			image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 0);
			image_select((t_gobj *)x, glist_getcanvas(x->x_glist), 1);
		}
		canvas_fixlinesfor(x->x_glist,(t_text*) x);
	}
}
示例#2
0
文件: embedded.c 项目: 3a9LL/panda
/**
 * Register all embedded images
 */
static void embedded_init ( void ) {
	int i;
	struct image *image;
	void *data;
	int rc;

	/* Skip if we have no embedded images */
	if ( ! sizeof ( embedded_images ) )
		return;

	/* Fix up data pointers and register images */
	for ( i = 0 ; i < ( int ) ( sizeof ( embedded_images ) /
				    sizeof ( embedded_images[0] ) ) ; i++ ) {
		image = &embedded_images[i];

		/* virt_to_user() cannot be used in a static
		 * initialiser, so we cast the pointer to a userptr_t
		 * in the initialiser and fix it up here.  (This will
		 * actually be a no-op on most platforms.)
		 */
		data = ( ( void * ) image->data );
		image->data = virt_to_user ( data );

		DBG ( "Embedded image \"%s\": %zd bytes at %p\n",
		      image->name, image->len, data );

		if ( ( rc = register_image ( image ) ) != 0 ) {
			DBG ( "Could not register embedded image \"%s\": "
			      "%s\n", image->name, strerror ( rc ) );
			return;
		}
	}

	/* Select the first image */
	image = &embedded_images[0];
	if ( ( rc = image_select ( image ) ) != 0 ) {
		DBG ( "Could not select embedded image \"%s\": %s\n",
		      image->name, strerror ( rc ) );
		return;
	}
}