int
main (int argc, char **argv)
{
	GdkWindow *root;
	GdkPixbuf *pixbuf;
	gboolean ret;
	gint retval = 1;
	GError *error = NULL;

	gtk_init (&argc, &argv);

	root = gdk_get_default_root_window ();
	pixbuf = gdk_pixbuf_get_from_window (root,
					     0, 0, 150, 160);

	/* PASS */
	g_debug ("try to save PNG with a profile");
	ret = save_image_png ("icc-profile.png", pixbuf, &error);
	if (!ret) {
		g_warning ("FAILED: did not save image: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* PASS */
	g_debug ("try to save TIFF with a profile");
	ret = save_image_tiff ("icc-profile.tiff", pixbuf, &error);
	if (!ret) {
		g_warning ("FAILED: did not save image: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* PASS */
	g_debug ("try to load PNG and get color attributes");
	ret = save_image_verify ("icc-profile.png", &error);
	if (!ret) {
		g_warning ("FAILED: did not load image: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* PASS */
	g_debug ("try to load TIFF and get color attributes");
	ret = save_image_verify ("icc-profile.tiff", &error);
	if (!ret) {
		g_warning ("FAILED: did not load image: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* success */
	retval = 0;
	g_debug ("ALL OKAY!");
out:
	return retval;
}
Exemple #2
0
int save_grid_png(grid_t *grid, char *output) {
	if (grid == NULL || output == NULL)
		goto error;

	image_t *img = grid_to_image(grid);
	ERR_NOMEM(img);

	return save_image_png(img, output);
error:
	return -1;
}
Exemple #3
0
void extract_cifar()
{
char *labels[] = {"airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"};
    int i;
    data train = load_all_cifar10();
    data test = load_cifar10_data("data/cifar/cifar-10-batches-bin/test_batch.bin");
    for(i = 0; i < train.X.rows; ++i){
        image im = float_to_image(32, 32, 3, train.X.vals[i]);
        int class = max_index(train.y.vals[i], 10);
        char buff[256];
        sprintf(buff, "data/cifar/train/%d_%s",i,labels[class]);
        save_image_png(im, buff);
    }
    for(i = 0; i < test.X.rows; ++i){
        image im = float_to_image(32, 32, 3, test.X.vals[i]);
        int class = max_index(test.y.vals[i], 10);
        char buff[256];
        sprintf(buff, "data/cifar/test/%d_%s",i,labels[class]);
        save_image_png(im, buff);
    }
}