Exemplo n.º 1
0
int
filter(struct image *img, xmlNodePtr node, void **instctx)
{
	struct image work;
	struct flipctx *ctx;
	unsigned int x, y, vy;
	unsigned char *r, *w;
	
	if (!*instctx) {
		ctx = ctx_init(node);
		*instctx = ctx;
	}
	else
		ctx = *instctx;
	
	if (!ctx->h && !ctx->v)
		return 0;
	
	image_dup(&work, img);

	/* 3x3
	 * 0/00 RGBRGBRGB
	 * 1/09 RGBRGBRGB
	 * 2/18 RGBRGBRGB */
	
	r = img->buf;
	for (y = 0; y < img->y; y++)
	{
		if (ctx->v)
			vy = img->y - y - 1;
		else
			vy = y;
			
		if (ctx->h)
			w = work.buf + (vy + 1) * work.x * 3 - 3;
		else
			w = work.buf + vy * work.x * 3;
		
		for (x = 0; x < img->x; x++)
		{
			w[0] = *r++;
			w[1] = *r++;
			w[2] = *r++;
			if (ctx->h)
				w -= 3;
			else
				w += 3;
		}
	}
	
	image_move(img, &work);
	
	return 0;
}
Exemplo n.º 2
0
int
filter(struct image *img, xmlNodePtr node)
{
	struct image work;
	unsigned int x, y, vy;
	unsigned char *r, *w;
	int h, v;
	char *cont;
	
	h = v = 0;
	
	for (node = node->xml_children; node; node = node->next)
	{
		if (xml_isnode(node, "horiz"))
		{
			cont = xml_getcontent(node);
			if (cont
				&& (!strcmp(cont, "yes")
					|| !strcmp(cont, "on")
					|| !strcmp(cont, "1")))
			h = 1;
		}
		else if (xml_isnode(node, "vert"))
		{
			cont = xml_getcontent(node);
			if (cont
				&& (!strcmp(cont, "yes")
					|| !strcmp(cont, "on")
					|| !strcmp(cont, "1")))
			v = 1;
		}
	}
	
	if (!h && !v)
		return 0;
	
	image_dup(&work, img);

	/* 3x3
	 * 0/00 RGBRGBRGB
	 * 1/09 RGBRGBRGB
	 * 2/18 RGBRGBRGB */
	
	r = img->buf;
	for (y = 0; y < img->y; y++)
	{
		if (v)
			vy = img->y - y - 1;
		else
			vy = y;
			
		if (h)
			w = work.buf + (vy + 1) * work.x * 3 - 3;
		else
			w = work.buf + vy * work.x * 3;
		
		for (x = 0; x < img->x; x++)
		{
			w[0] = *r++;
			w[1] = *r++;
			w[2] = *r++;
			if (h)
				w -= 3;
			else
				w += 3;
		}
	}
	
	image_move(img, &work);
	
	return 0;
}
Exemplo n.º 3
0
static int image_handle_input(dword * selidx, dword key)
{
	slideshow_move = false;

#ifdef ENABLE_ANALOG
	if (config.img_enable_analog) {
		int x, y, orgtop = curtop, orgleft = curleft;

		if (ctrl_analog(&x, &y)) {
			slideshow_move = true;
			x = x / 31 * (int) config.imgmvspd / 2;
			y = y / 31 * (int) config.imgmvspd / 2;
			curtop += y;

			if (curtop + imgh > height_rotated)
				curtop = (int) height_rotated - imgh;

			if (curtop < 0)
				curtop = 0;

			curleft += x;

			if (curleft + PSP_SCREEN_WIDTH > width_rotated)
				curleft = (int) width_rotated - PSP_SCREEN_WIDTH;

			if (curleft < 0)
				curleft = 0;

			thumb = (config.thumb == conf_thumb_scroll);
			img_needrp = (thumb || orgtop != curtop || orgleft != curleft);
		}
	}
#endif

	if (key == 0)
		goto next;

	if (!slideshow || (key != CTRL_FORWARD && key != 0))
		secticks = 0;

	if (key == (PSP_CTRL_SELECT | PSP_CTRL_START)) {
		return exit_confirm();
	} else if (key == PSP_CTRL_SELECT) {
		bool lastbicubic = config.bicubic;

		img_needrp = true;

		if (scene_options(selidx)) {
			imgreading = false;
			reset_image_ptr();

			return *selidx;
		}

		if (lastbicubic != config.bicubic)
			img_needrc = true;

		if (config.imginfobar)
			imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE;
		else
			imgh = PSP_SCREEN_HEIGHT;

	} else if (key == PSP_CTRL_START) {
		scene_mp3bar();
		img_needrp = true;
	} else if (key == config.imgkey[1] || key == config.imgkey2[1]
			   || key == CTRL_FORWARD) {
		bool should_exit = false;

		if (config.imgpaging == conf_imgpaging_updown ||
			config.imgpaging == conf_imgpaging_leftright)
			xrKernelDelayThread(200000);

		if (!image_paging(true, config.imgpaging))
			goto next;

		next_image(selidx, &should_exit);

		if (should_exit) {
			return *selidx;
		}
	} else if (key == config.imgkey[0] || key == config.imgkey2[0]
			   || key == CTRL_BACK) {
		if (config.imgpaging == conf_imgpaging_updown ||
			config.imgpaging == conf_imgpaging_leftright)
			xrKernelDelayThread(200000);

		if (!image_paging(false, config.imgpaging))
			goto next;

		prev_image(selidx);
	} else if (key == config.imgkey[2] || key == config.imgkey2[2]) {
		ctrl_waitrelease();

		if (config.fit == conf_fit_custom)
			config.fit = conf_fit_none;
		else
			config.fit++;

		img_needrc = img_needrp = true;
	} else if (key == config.imgkey[10] || key == config.imgkey2[10]) {
		config.bicubic = !config.bicubic;
		img_needrc = img_needrp = true;
	} else if (key == config.imgkey[11] || key == config.imgkey2[11]) {
		if (!slideshow) {
			slideshow = true;
			lasttime = time(NULL);
			ctrl_waitrelease();
		} else {
			slideshow = false;
			win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE,
					COLOR_WHITE, config.msgbcolor);
			ctrl_waitrelease();
		}
	} else if (key == config.imgkey[7] || key == config.imgkey2[7]) {
		SceCtrlData ctl;
		int t = 0;

		config.imginfobar = !config.imginfobar;

		if (config.imginfobar)
			imgh = PSP_SCREEN_HEIGHT - DISP_FONTSIZE;
		else
			imgh = PSP_SCREEN_HEIGHT;

		if (height_rotated > imgh && curtop > height_rotated - imgh)
			curtop = height_rotated - imgh;

		img_needrc = (config.fit == conf_fit_height);
		img_needrp = true;

		do {
			xrCtrlReadBufferPositive(&ctl, 1);
			xrKernelDelayThread(10000);
			t += 10000;
		} while (ctl.Buttons != 0 && t <= 500000);
	} else if (key == config.imgkey[9] || key == config.imgkey2[9]
			   || key == CTRL_PLAYPAUSE) {
		if (slideshow) {
			slideshow = false;
			win_msg(_("幻灯片播放已经停止!"), COLOR_WHITE,
					COLOR_WHITE, config.msgbcolor);
			ctrl_waitrelease();
		} else {
			imgreading = false;
			reset_image_ptr();

			return *selidx;
		}
	} else if (key == config.imgkey[8] || key == config.imgkey2[8]) {
		if (!slideshow && !showinfo) {
			img_needrp = true;
			showinfo = true;
		}
	} else if (key == config.imgkey[5] || key == config.imgkey2[5]) {
		if (config.rotate == conf_rotate_0)
			config.rotate = conf_rotate_270;
		else
			config.rotate--;

		ctrl_waitreleasekey(key);
		img_needrc = img_needrp = true;
	} else if (key == config.imgkey[6] || key == config.imgkey2[6]) {
		if (config.rotate == conf_rotate_270)
			config.rotate = conf_rotate_0;
		else
			config.rotate++;

		ctrl_waitreleasekey(key);
		img_needrc = img_needrp = true;
	} else if (key == config.imgkey[3] || key == config.imgkey2[3]) {
		if (config.scale > 200)
			config.scale -= 50;
		else if (config.scale > 10)
			config.scale -= 5;
		else
			goto next;

		config.fit = conf_fit_custom;
		img_needrc = img_needrp = true;
		ctrl_waitreleasekey(key);
	} else if (key == config.imgkey[4] || key == config.imgkey2[4]) {
		if (config.scale < 200)
			config.scale += 5;
		else if (config.scale < 1000)
			config.scale += 50;
		else
			goto next;

		config.fit = conf_fit_custom;
		img_needrc = img_needrp = true;
		ctrl_waitreleasekey(key);
	} else if (key &
			   (config.imgkey[12] | config.imgkey[13] | config.
				imgkey[14] | config.imgkey[15] | config.imgkey2[12] | config.
				imgkey2[13] | config.imgkey2[14] | config.imgkey2[15])
			   && !(key &
					~(config.imgkey[12] | config.imgkey[13] | config.
					  imgkey[14] | config.imgkey[15] | config.
					  imgkey2[12] | config.imgkey2[13] | config.
					  imgkey2[14] | config.imgkey2[15]
					))) {
		slideshow_move = true;
		image_move(key);
	} else
		img_needrf = img_needrc = false;

  next:
	return -1;
}