Differenze tra le versioni di "Convertire un'immagine in un file immagine di formato ICO mediante le funzioni esterne del API di Libgdk pixbuf"

Da Gambas-it.org - Wikipedia.
Riga 11: Riga 11:
 
  ' ''Creates a new pixbuf by loading an image from a file.''</font>
 
  ' ''Creates a new pixbuf by loading an image from a file.''</font>
 
  Private Extern gdk_pixbuf_new_from_file(filename As String, GError As Pointer) As Pointer
 
  Private Extern gdk_pixbuf_new_from_file(filename As String, GError As Pointer) As Pointer
+
 
<FONT Color=gray>' ''GdkPixbuf * gdk_pixbuf_copy (const GdkPixbuf *pixbuf)''
 
' ''Creates a new GdkPixbuf with a copy of the information in the specified pixbuf.''</font>
 
Private Extern gdk_pixbuf_copy(GdkPixbuf As Pointer) As Pointer
 
 
 
  <FONT Color=gray>' ''gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf, const char *filename, const char *type, GError **error, ...)''
 
  <FONT Color=gray>' ''gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf, const char *filename, const char *type, GError **error, ...)''
 
  ' ''Saves pixbuf to a file in format type. By default, "jpeg", "png", "ico" and "bmp" are possible file formats to save in.''</font>
 
  ' ''Saves pixbuf to a file in format type. By default, "jpeg", "png", "ico" and "bmp" are possible file formats to save in.''</font>
Riga 29: Riga 25:
 
   If err <> 0 Then Error.Raise("Impossibile caricare l'immagine !")
 
   If err <> 0 Then Error.Raise("Impossibile caricare l'immagine !")
 
      
 
      
  pixbuf = gdk_pixbuf_copy(pixbuf)
 
 
 
 
  <FONT Color=gray>' ''In questo esempio salveremo l'immagine, convertita in formato .ico, nella cartella "/tmp":''</font>
 
  <FONT Color=gray>' ''In questo esempio salveremo l'immagine, convertita in formato .ico, nella cartella "/tmp":''</font>
 
   gdk_pixbuf_save(pixbuf, "''/tmp/file_icona.ico''", "ico", VarPtr(err), Null)
 
   gdk_pixbuf_save(pixbuf, "''/tmp/file_icona.ico''", "ico", VarPtr(err), Null)

Versione delle 18:19, 15 nov 2015

La libreria GDK-PixBuf consente il caricamento delle immagini e la manipolazione del buffer dei pixel.

Per poter fruire in Gambas delle risorse di questa libreria è necessario installare e richiamare la libreria condivisa e dinamica: "libgdk_pixbuf-2.0.so.0.3000.7"


La libreria GDK-PixBuf consente anche di convertire e salvare un'immagine in un file immagine di formato .ICO
Ne mostriamo un semplice esempio:

Library "libgdk_pixbuf-2.0:0.3000.7"

' 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
 
' gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf, const char *filename, const char *type, GError **error, ...)
' Saves pixbuf to a file in format type. By default, "jpeg", "png", "ico" and "bmp" are possible file formats to save in.
Private Extern gdk_pixbuf_save(GdkPixbuf As Pointer, filename As String, type As String, GErr As Pointer, altro As String) As Boolean


Public Sub Main()

 Dim pixbuf, err As Pointer
 Dim imm As String = "/percorso/della/immagine/da/convertire"
 
  pixbuf = gdk_pixbuf_new_from_file(imm, VarPtr(err))
  If err <> 0 Then Error.Raise("Impossibile caricare l'immagine !")
   
' In questo esempio salveremo l'immagine, convertita in formato .ico, nella cartella "/tmp":
  gdk_pixbuf_save(pixbuf, "/tmp/file_icona.ico", "ico", VarPtr(err), Null)
  If err <> 0 Then Error.Raise("Impossibile salvare l'immagine in formato .ICO !")
       
End



Riferimenti