Using GTK as a Framework there is the need to insert images, photos or other graphic formats to display, this is GTK_Image, currently alone it can only display an image, but in some cases you need to resize it to be inserted in an elegant or comfortable way inside the work window.
'Code explained by TJF
VAR height = 200, fnam = "myfile.png"
DIM AS GError PTR errr
VAR pixbuf = gdk_pixbuf_new_from_file_at_scale(fnam, -1, height, TRUE, @errr)
IF 0 = errr THEN
gtk_image_set_from_pixbuf(GTK_IMAGE(ViewImage), pixbuf)
ELSE
?"Loading image failed: "; *errr->message
g_error_free(errr)
gtk_quit()
END IF
'Thank you TJF
Thank you.
Last edited by exagonx on Nov 14, 2020 11:03, edited 2 times in total.
GdkPixbuf is a structure holding Information that describes an image. It's not made for rezising.
Assuming you're talking about Gtk3:
I'd load the image in a cairo surface, scale (share, rotate) it and afterwards call gtk_image_set_from_surface(GTK_IMAGE(ViewImage), cairo_surface).
Regards
@Admin:
This is not a Linux specific topic. Can you please move it to section Libraries.
GdkPixbuf is a structure holding Information that describes an image. It's not made for rezising.
Assuming you're talking about Gtk3:
I'd load the image in a cairo surface, scale (share, rotate) it and afterwards call gtk_image_set_from_surface(GTK_IMAGE(ViewImage), cairo_surface).
.
Thank you for the answer TJF
Its a way to know header and how use it for resize all image to the specific size ?
' ...
VAR height = 32, fnam = "MyImage.jpg"
DIM AS GError PTR errr
VAR pixbuf = gdk_pixbuf_new_from_file_at_scale(fnam, -1, height, TRUE, @errr)
IF 0 = errr THEN
gtk_image_set_from_pixbuf(GTK_IMAGE(ViewImage), pixbuf)
ELSE
?"Loading image failed: "; *errr->message
g_error_free(errr)
gtk_quit()
END IF
@exagonx
I dislike the way you're asking / cooperating.
@exagonx
I dislike the way you're asking / cooperating.
I'm sorry, unfortunately I don't know a different way to express myself, English is not my language.
In any case feel free to correct me this will make you more friendly in my eyes.