Differenze tra le versioni di "Conoscere i formati immagine disponibili con GTK mediante le funzioni del API di GDK-PixBuf"
Da Gambas-it.org - Wikipedia.
Riga 3: | Riga 3: | ||
Alcune sue funzioni ci consentono di conoscere quali sono i formati di file immagine disponibili con ''GTK'' anche in riferimento ai formati immagine, nei quali esse possono essere salvate. | Alcune sue funzioni ci consentono di conoscere quali sono i formati di file immagine disponibili con ''GTK'' anche in riferimento ai formati immagine, nei quali esse possono essere salvate. | ||
− | E' necessario avere installata nel proprio sistema e richiamare in Gambas la libreria dinamica condivisa: "''libgtk-3.so.0.2404.16''". | + | E' necessario avere installata nel proprio sistema e richiamare in Gambas la libreria dinamica condivisa: "''libgtk-3.so.0.2404.16'' ". |
− | |||
Nel seguente esempio verranno mostrati: | Nel seguente esempio verranno mostrati: | ||
Riga 10: | Riga 9: | ||
* i formati immagine che possono essere solo letti e quelli che consentono anche la scrittura (il salvataggio) dei file immagine; | * i formati immagine che possono essere solo letti e quelli che consentono anche la scrittura (il salvataggio) dei file immagine; | ||
* una breve descrizione del formato immagine disponibile. | * una breve descrizione del formato immagine disponibile. | ||
+ | Library "libgtk-3:0.2404.16" | ||
+ | |||
Public Struct GdkPixbufFormat | Public Struct GdkPixbufFormat | ||
name As Pointer | name As Pointer | ||
Riga 21: | Riga 22: | ||
license As Pointer | license As Pointer | ||
End Struct | End Struct | ||
− | + | ||
− | |||
− | |||
− | |||
<FONT Color=gray>' ''GSList * gdk_pixbuf_get_formats (void)'' | <FONT Color=gray>' ''GSList * gdk_pixbuf_get_formats (void)'' | ||
' ''Obtains the available information about the image formats supported by GdkPixbuf.''</font> | ' ''Obtains the available information about the image formats supported by GdkPixbuf.''</font> |
Versione delle 19:38, 19 nov 2021
GDK-PixBuf è una libreria grafica per il caricamento e la manipolazione delle immagini.
Alcune sue funzioni ci consentono di conoscere quali sono i formati di file immagine disponibili con GTK anche in riferimento ai formati immagine, nei quali esse possono essere salvate.
E' necessario avere installata nel proprio sistema e richiamare in Gambas la libreria dinamica condivisa: "libgtk-3.so.0.2404.16 ".
Nel seguente esempio verranno mostrati:
- i formati immagine disponibili;
- i formati immagine che possono essere solo letti e quelli che consentono anche la scrittura (il salvataggio) dei file immagine;
- una breve descrizione del formato immagine disponibile.
Library "libgtk-3:0.2404.16" Public Struct GdkPixbufFormat name As Pointer signature As Pointer domain As Pointer description As Pointer mime_types As Pointer extensions As Pointer flags As Integer disabled As Boolean license As Pointer End Struct ' GSList * gdk_pixbuf_get_formats (void) ' Obtains the available information about the image formats supported by GdkPixbuf. Private Extern gdk_pixbuf_get_formats() As Pointer ' void g_slist_foreach (GSList *list, GFunc func, gpointer user_data) ' Calls a function for each element of a GSList. Private Extern g_slist_foreach(list As Pointer, func As Pointer, user_data As Pointer) ' void g_slist_free (GSList *list) ' Frees all of the memory used by a GSList. Private Extern g_slist_free(list As Pointer) ' gchar * gdk_pixbuf_format_get_name (GdkPixbufFormat *format) ' Returns the name of the format. Private Extern gdk_pixbuf_format_get_name(GDKformat As GdkPixbufFormat) As String ' gboolean gdk_pixbuf_format_is_writable (GdkPixbufFormat *format) ' Returns whether pixbufs can be saved in the given format. Private Extern gdk_pixbuf_format_is_writable(GDKformat As GdkPixbufFormat) As Boolean ' gchar * gdk_pixbuf_format_get_description (GdkPixbufFormat *format) ' Returns a description of the format. Private Extern gdk_pixbuf_format_get_description(GDKformat As GdkPixbufFormat) As String Public Sub Main() Dim formats As Pointer formats = gdk_pixbuf_get_formats() g_slist_foreach(formats, elenco_formati, Null) g_slist_free(formats) End Private Function elenco_formati(data As Pointer, user_data As Pointer) Dim PixbufFormat As New GdkPixbufFormat Dim formato, cap, des As String PixbufFormat = data formato = gdk_pixbuf_format_get_name(PixbufFormat) If gdk_pixbuf_format_is_writable(PixbufFormat) Then cap = "rw" Else cap = "r" Endif des = gdk_pixbuf_format_get_description(PixbufFormat) Print formato; " "; Null, cap, Null; des End