Example #1
3
TILP_EXPORT void on_scdbox_button1_clicked(GtkButton * button, gpointer user_data)
{
    GdkPixbuf *pixbuf;
    guchar *bytemap;
    gint w, h;

    if (screen_capture())
    {
        screen_success = FALSE;
        return;
    }
    else
    {
        screen_success = TRUE;
    }

    w = screen.width;
    h = screen.height;

    switch (screen.pixel_format)
    {
    case CALC_PIXFMT_MONO:
        if (options.screen_blurry)
            bytemap = screen_bw_blurry();
        else
            bytemap = screen_bw_convert();
        break;

    case CALC_PIXFMT_GRAY_4:
        // Nspire (CAS) Clickpad or Touchpad.
        bytemap = screen_gs_convert();
        break;

    case CALC_PIXFMT_RGB_5_6_5:
        // Nspire (CAS) CX or TI-84 Plus CSE.
        bytemap = screen_16bitcolor_convert();
        break;

    default:
        tilp_critical(_("Unknown calculator model with pixel_format=%d\n"), screen.pixel_format);
        screen_success = FALSE;
        return;
    }

    pixbuf = gdk_pixbuf_new_from_data(bytemap, GDK_COLORSPACE_RGB, FALSE,
                                      8, w, h, 3 * w, destroy_pixbuf, NULL);
    gtk_image_set_from_pixbuf(GTK_IMAGE(scrn_img), pixbuf);
    g_object_unref(pixbuf);
}
Example #2
1
TILP_EXPORT void on_scdbox_button1_clicked(GtkButton * button,
					gpointer user_data)
{
	GdkPixbuf *pixbuf;
	guchar *bytemap;
	gint w, h;

	if (screen_capture())
	{
		screen_success = FALSE;
		return;
	} 
	else
	{
		screen_success = TRUE;
	}
	
	w = screen.width;
	h = screen.height;

	if(options.calc_model != CALC_NSPIRE)
	{
		if (options.screen_blurry)
			bytemap = screen_bw_blurry();
		else
			bytemap = screen_bw_convert();
	}
	else
	{
		// For Nspires, we have to determine the calc model...
		CalcInfos infos;
		if (ticalcs_calc_get_version(calc_handle, &infos))
		{
			screen_success = FALSE;
			return;
		}

		if (infos.bits_per_pixel == 4)
		{
			// Nspire (CAS) Clickpad or Touchpad.
			bytemap = screen_gs_convert();
		}
		else if (infos.bits_per_pixel == 16)
		{
			// Nspire (CAS) CX.
			bytemap = screen_16bitcolor_convert();
		}
		else
		{
			tilp_critical(_("Unknown calculator model with %d bpp\n"), infos.bits_per_pixel);
			screen_success = FALSE;
			return;
		}
	}

	pixbuf = gdk_pixbuf_new_from_data(bytemap, GDK_COLORSPACE_RGB, FALSE,
				     8, w, h, 3 * w, destroy_pixbuf, NULL);
	gtk_image_set_from_pixbuf(GTK_IMAGE(scrn_img), pixbuf);
	g_object_unref(pixbuf);
}
Example #3
0
File: rgb.c Project: doremi/game
int main(int argc, char **argv)
{
	unsigned short *image565 = screen_init();
	struct image *image = image_new(WIDTH, HEIGHT);
	struct image *font = image_new(BLOCK_X, BLOCK_Y*50);
	struct Glyph glyph[50];
	int i;

	recognize_init();
	event_init();
	image_load(font, "data.raw");
	memset(glyph, 0, sizeof(glyph));

	printf("Press any key to start...");
	getc(stdin);
	printf("Recognizing 1~25 ...\n");

	screen_capture(image565);
	rgb565_to_rgb24(image->buf, image565);
	threshold(THRESHOLD, image->buf);
	recognize(image, font, glyph, 0);

	for (i = 0; i < 25; ++i) {
		send_touch(glyph[i].x, glyph[i].y);
		usleep(100);
	}

	printf("\n\nPress any key to continue...");
	getc(stdin);
	printf("Recognizing 26~50 ...\n");

	screen_capture(image565);
	rgb565_to_rgb24(image->buf, image565);
	threshold(THRESHOLD, image->buf);
	recognize(image, font, glyph, 1);

	for (i = 24; i < 50; ++i) {
		send_touch(glyph[i].x, glyph[i].y);
		usleep(100);
	}

	image_destroy(font);
	event_destroy();
	image_destroy(image);
	screen_destroy(image565);

	return 0;
}