Get GtkPicture / GtkImage size

| 0 Comments| | 04:03
Categories:

GtkPicture

void ShowPictureSize()
{
    GtkWidget *picture;
    GdkPaintable *paintable;
    picture = gtk_picture_new_for_filename("./sample.jpg");
    paintable = gtk_picture_get_paintable(GTK_PICTURE(picture));
    if (paintable)
        g_print("The picture size is %ux%u pixels.\n", gdk_paintable_get_intrinsic_width(paintable), gdk_paintable_get_intrinsic_height(paintable));
}

 

GtkImage

void ShowImageSize()
{
    GtkWidget *image;
    GdkPaintable *paintable;
    image = gtk_image_new_from_file("./sample.jpg");
    paintable = gtk_image_get_paintable(GTK_IMAGE(image));
    if (paintable)
        g_print("The image size is %ux%u pixels.\n", gdk_paintable_get_intrinsic_width(paintable), gdk_paintable_get_intrinsic_height(paintable));
}

 
#c #gtk4 #gdk4 #gdkpixbuf2
#fedora36 #ubuntu22.04 #gnome42.4

Leave a Reply

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *