Get GdkPixbuf / GdkTexture / GdkPaintable Size

| 0 Comments| | 04:04
Categories:

GdkPixbuf

void ShowGdkPixbufSize()
{
    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file("./image/2.bmp", NULL);
    g_print("The pixbuf size is %ux%u pixels.\n", gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
    g_object_unref(pixbuf);
}

 

GdkTexture

void ShowGdkTextureSize()
{
    GdkTexture *texture = gdk_texture_new_from_filename("./image/3.png", NULL);
    g_print("The texture size is %ux%u pixels.\n", gdk_texture_get_width(texture), gdk_texture_get_height(texture));
    g_object_unref(texture);
}

 

GdkPaintable

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));
}

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

Leave a Reply

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