Differenze tra le versioni di "Ottenere alcune informazioni sul file immagine con le funzioni del API di GTK+3 e GDK-PixBuf"

Da Gambas-it.org - Wikipedia.
Riga 3: Riga 3:
 
Fra molteplici potenzialità esse consentono di ottenere alcune informazioni sui file immagine.
 
Fra molteplici potenzialità esse consentono di ottenere alcune informazioni sui file immagine.
  
Sarà necessario avere installata nel sistema la libreria: "''libgtk-3.so.0.1800.9''".
+
Sarà necessario avere installata nel sistema la libreria: "''libgtk-3.so.0.2200.30''".
  
  
Riga 20: Riga 20:
 
  End Struct
 
  End Struct
 
   
 
   
  Library "libgtk-3:0.1800.9"
+
  Library "libgtk-3:0.2200.30"
 
   
 
   
 
  <FONT Color=gray>' ''GdkPixbuf * gdk_pixbuf_new_from_file (const char *filename, GError **error)''
 
  <FONT Color=gray>' ''GdkPixbuf * gdk_pixbuf_new_from_file (const char *filename, GError **error)''
Riga 78: Riga 78:
 
   
 
   
 
   With PixbufFormat
 
   With PixbufFormat
     Print String@(.name)                  <FONT Color=gray>' ''Il nome del formato immagine''</font>
+
     Print "Name:        "; String@(.name)                  <FONT Color=gray>' ''Il nome del formato immagine''</font>
     Print String@(.domain)                <FONT Color=gray>' ''Il contrassegno del modulo''</font>
+
     Print "Domain:      "; String@(.domain)                <FONT Color=gray>' ''Il contrassegno del modulo''</font>
     Print String@(.description)          <FONT Color=gray>' ''Il dominio del messaggio per la descrizione''</font>
+
     Print "Description: "; String@(.description)          <FONT Color=gray>' ''Il dominio del messaggio per la descrizione''</font>
     Print String@(Pointer@(.mime_types))  <FONT Color=gray>' ''Una descrizione del formato immagine''</font>
+
     Print "Mime-Type:  "; String@(Pointer@(.mime_types))  <FONT Color=gray>' ''Una descrizione del formato immagine''</font>
     Print String@(Pointer@(.extensions))  <FONT Color=gray>' ''Un array di MIME-types del formato immagine''</font>
+
     Print "Extension:  "; String@(Pointer@(.extensions))  <FONT Color=gray>' ''Un array di MIME-types del formato immagine''</font>
     Print .flags                         <FONT Color=gray>' ''Combinazione di flags che specifica ulteriori dettagli sulle operazioni supportate''</font>
+
     Print "Flag:        ".flags               <FONT Color=gray>' ''Combinazione di flags che specifica ulteriori dettagli sulle operazioni supportate''</font>
     Print String@(.license)               <FONT Color=gray>' ''Informazione sulla licenza relativa al formato immagine''</font>
+
     Print "License: "; String@(.license)     <FONT Color=gray>' ''Informazione sulla licenza relativa al formato immagine''</font>
 
   End With
 
   End With
 
   
 
   

Versione delle 18:15, 25 dic 2019

GTK+3 è una libreria per la creazione di interfacce grafiche utente. GDK-PixBuf è una libreria grafica per il caricamento e la manipolazione delle immagini.

Fra molteplici potenzialità esse consentono di ottenere alcune informazioni sui file immagine.

Sarà necessario avere installata nel sistema la libreria: "libgtk-3.so.0.2200.30".


Mostriamo un semplice esempio pratico:

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

Library "libgtk-3:0.2200.30"

' GdkPixbuf * gdk_pixbuf_new_from_file (const char *filename, GError **error)
' Creates a new pixbuf by loading an image from a file.
Private Extern gdk_pixbuf_new_from_file(filename As String, GError As Pointer) As Pointer

' guchar * gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
' Queries a pointer to the pixel data of a pixbuf.
Private Extern gdk_pixbuf_get_pixels(GdkPixbuf As Pointer) As Pointer

' int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
' Queries the width of a pixbuf.
Private Extern gdk_pixbuf_get_width(GdkPixbuf As Pointer) As Integer

' int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
' Queries the height of a pixbuf.
Private Extern gdk_pixbuf_get_height(GdkPixbuf As Pointer) As Integer

' int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
' Queries the number of channels of a pixbuf.
Private Extern gdk_pixbuf_get_n_channels(GdkPixbuf As Pointer) As Integer

' gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
' Queries whether a pixbuf has an alpha channel (opacity information).
Private Extern gdk_pixbuf_get_has_alpha(GdkPixbuf As Pointer) As Boolean

' GdkPixbufFormat * gdk_pixbuf_get_file_info (const gchar *filename, gint *width, gint *height)
' Parses an image file far enough to determine its format and size.
Private Extern gdk_pixbuf_get_file_info(filename As String, width As Pointer, height As Pointer) As Pointer


Public Sub Main()

 Dim nomefile As String = "/percorso/del/file/immagine"
 Dim w, wi, h, hi As Integer
 Dim Pixbuf As Pointer
 Dim c As Byte
 Dim bo As Boolean
 Dim PixbufFormat As New GdkPixbufFormat

  Pixbuf = gdk_pixbuf_new_from_file(nomefile, 0)

  w = gdk_pixbuf_get_width(Pixbuf)
  Print "Larghezza: "; Null, w; " pixel"
  h = gdk_pixbuf_get_height(Pixbuf)
  Print "Altezza: "; Null, h; " pixel"
  c = gdk_pixbuf_get_n_channels(Pixbuf)
  Print "Canali: "; Null, c
  bo = gdk_pixbuf_get_has_alpha(Pixbuf)
  Print "Canale Alfa: "; Null, bo

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  PixbufFormat = gdk_pixbuf_get_file_info(nomefile, VarPtr(wi), VarPtr(hi))
  Print "\nLarghezza: "; Null, wi; " pixel"
  Print "Altezza: "; Null, hi; " pixel"

  With PixbufFormat
    Print "Name:        "; String@(.name)                  ' Il nome del formato immagine
    Print "Domain:      "; String@(.domain)                ' Il contrassegno del modulo
    Print "Description: "; String@(.description)           ' Il dominio del messaggio per la descrizione
    Print "Mime-Type:   "; String@(Pointer@(.mime_types))  ' Una descrizione del formato immagine
    Print "Extension:   "; String@(Pointer@(.extensions))  ' Un array di MIME-types del formato immagine
    Print "Flag:        ".flags               ' Combinazione di flags che specifica ulteriori dettagli sulle operazioni supportate
    Print "License: "; String@(.license)      ' Informazione sulla licenza relativa al formato immagine
  End With

End



Riferimenti