int main (int argc, char **argv) { int i; int found_valid = FALSE; GdkPixbuf *pixbuf; GdkPixbufLoader *pixbuf_loader; gtk_init (&argc, &argv); gdk_rgb_set_verbose (TRUE); gdk_rgb_init (); gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); gtk_widget_set_default_visual (gdk_rgb_get_visual ()); { char *tbf_readlen = getenv("TBF_READLEN"); if(tbf_readlen) readlen = atoi(tbf_readlen); } { char *tbf_bps = getenv("TBF_KBPS"); guint bps; if (tbf_bps) { bps = atoi(tbf_bps); g_print ("Simulating %d kBytes/sec\n", bps); readlen = (bps*1024)/10; } } i = 1; if (argc == 1) { const gchar*** xpmp; pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3, NULL, NULL); new_testrgb_window (pixbuf, NULL); xpmp = xpms; while (*xpmp) { pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp); new_testrgb_window (pixbuf, NULL); ++xpmp; } found_valid = TRUE; } else { for (i = 1; i < argc; i++) { pixbuf = gdk_pixbuf_new_from_file (argv[i]); #if 0 pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0); #endif if (pixbuf) { new_testrgb_window (pixbuf, "File"); found_valid = TRUE; } } #if 1 { GtkWidget* rgb_window = NULL; ProgressFileStatus status; pixbuf_loader = gdk_pixbuf_loader_new (); status.loader = pixbuf_loader; status.rgbwin = &rgb_window; status.buf = g_malloc (readlen); gtk_signal_connect(GTK_OBJECT(pixbuf_loader), "area_prepared", GTK_SIGNAL_FUNC(progressive_prepared_callback), &rgb_window); gtk_signal_connect(GTK_OBJECT(pixbuf_loader), "area_updated", GTK_SIGNAL_FUNC(progressive_updated_callback), &rgb_window); status.imagefile = fopen (argv[1], "r"); g_assert (status.imagefile != NULL); status.readlen = readlen; status.timeout = gtk_timeout_add(100, update_timeout, &status); } #endif } if (found_valid) gtk_main (); return 0; }
int main (int argc, char **argv) { int i; int found_valid = FALSE; GdkPixbuf *pixbuf; GdkPixbufLoader *pixbuf_loader; pixbuf_init (); gtk_init (&argc, &argv); /* gdk_rgb_set_verbose (TRUE);*/ gtk_widget_set_default_colormap (gdk_rgb_get_colormap ()); { char *tbf_readlen = getenv ("TBF_READLEN"); if (tbf_readlen) readlen = atoi (tbf_readlen); } { char *tbf_bps = getenv ("TBF_KBPS"); guint bps; if (tbf_bps) { bps = atoi (tbf_bps); g_print ("Simulating %d kBytes/sec\n", bps); readlen = (bps*1024)/10; } } i = 1; if (argc == 1) { const gchar*** xpmp; GError *error = NULL; pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3, NULL, NULL); new_testrgb_window (pixbuf, NULL); xpmp = xpms; while (*xpmp) { pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp); new_testrgb_window (pixbuf, NULL); ++xpmp; } /* Test loading from inline data. */ pixbuf = gdk_pixbuf_new_from_inline (-1, apple_red, FALSE, &error); if (!pixbuf) { fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n", error->message); g_error_free (error); } else new_testrgb_window (pixbuf, "Red apple from inlined RLE data"); pixbuf = gdk_pixbuf_new_from_inline (sizeof (gnome_foot), gnome_foot, TRUE, NULL); new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data"); found_valid = TRUE; } else { for (i = 1; i < argc; i++) { GError *error; error = NULL; pixbuf = gdk_pixbuf_new_from_file (argv[i], &error); if (pixbuf == NULL) { g_warning ("Error loading image: %s", error->message); g_error_free (error); } #if 0 pixbuf = gdk_pixbuf_rotate (pixbuf, 10.0); #endif if (pixbuf) { new_testrgb_window (pixbuf, "File"); found_valid = TRUE; } } #if 1 { GtkWidget* rgb_window = NULL; ProgressFileStatus status; pixbuf_loader = gdk_pixbuf_loader_new (); status.loader = pixbuf_loader; status.rgbwin = &rgb_window; status.buf = g_malloc (readlen); #if 0 g_signal_connect (pixbuf_loader, "size_prepared", G_CALLBACK (size_func), NULL); #endif g_signal_connect (pixbuf_loader, "area_prepared", G_CALLBACK (progressive_prepared_callback), &rgb_window); g_signal_connect (pixbuf_loader, "area_updated", G_CALLBACK (progressive_updated_callback), &rgb_window); status.imagefile = fopen (argv[1], "r"); g_assert (status.imagefile != NULL); status.readlen = readlen; status.timeout = gdk_threads_add_timeout (100, update_timeout, &status); } #endif } if (found_valid) gtk_main (); return 0; }