why the "area-prepared" signal not be emitted

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



my English is poor, maybe I couldn't convey my trouble exactly... so I just paste partial codes....
the words in red color is some more detail explanation

        ...........................................
        .............................................
        ...........................................

        /***  this section I have filled a buffer by the file input stream  ***/
        GError *error = NULL;
        GInputStream *input_stream;
        GFile *file = g_file_new_for_path("../Pictures/123.png");
        GFileInfo *file_info = g_file_query_info(file, "*", G_FILE_QUERY_INFO_NONE, NULL, &error);
        guint64 file_size = g_file_info_get_attribute_uint64(file_info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
        input_stream = g_file_read(file, NULL, &error);
        guchar *buffer = g_malloc0(file_size);
        g_printf("file size:%d, %d\n", sizeof(buffer), file_size);
        g_input_stream_read(input_stream, buffer, file_size, NULL, &error);

        /***  and  in this section I use GdkPixbufLoader to load the data which in buffer into a Pixbuf, the gdk_pixbuf_loader_write() method returns true  ***/
        /***  thus the gdk_pixbuf_loader_close() method is called subsequently ***/
        /***  but the two callback method below both never been called at all  ***/
        /***  is there anything wrong with my code ? ***/
        /***  please help me ... thanks very much ***/
        GdkPixbuf *pixbuf = NULL;
        GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
        //GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_type("png",&error);
        g_signal_connect(loader, "area-prepared", G_CALLBACK(gdk_pixbuf_loader_area_prepared), &pixbuf);
        g_signal_connect(loader, "size-prepared", G_CALLBACK(gdk_pixbuf_loader_size_prepared), &pixbuf);
        //g_signal_connect(loader, "closed", G_CALLBACK(gdk_pixbuf_loader_area_prepared), &pixbuf);

        if(TRUE == gdk_pixbuf_loader_write(loader, buffer, sizeof(buffer), &error)){
            //g_printf("Error Code: %d, Message: %s\n",error->code, error->message);
            g_printf("success.\n");
        }
        gdk_pixbuf_loader_close(loader, NULL);
        g_printf("loader closed.\n");

        if(error != NULL){
            g_error_free(error);
        }
    }
}

void gdk_pixbuf_loader_size_prepared(GdkPixbufLoader *loader, gint width, gint height, gpointer user_data) {
    g_printf("%d, %d\n",width, height);
}

void gdk_pixbuf_loader_area_prepared(GdkPixbufLoader *loader, gpointer user_data){
    g_printf("enter area_prepared handler.\n");
    GdkPixbuf *pixbuf = *(GdkPixbuf **)user_data;
    pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);

    image = gtk_image_new_from_pixbuf(pixbuf);
        GdkRectangle rect;
        rect.x = 0;
        rect.y = 0;
        rect.width = gdk_window_get_width(window->window);
        rect.height = gdk_window_get_height(window->window);
        gdk_window_invalidate_region(window->window, gdk_region_rectangle(&rect), TRUE);
        gdk_window_process_updates(window->window, TRUE);
}
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux