Differenze tra le versioni di "Ottenere alcune informazioni su file immagine GIF con le funzioni del API di GifLib"

Da Gambas-it.org - Wikipedia.
Riga 18: Riga 18:
 
   Dim fl As File
 
   Dim fl As File
 
   Dim percorso As String = "''/percorso/del/file.gif''"
 
   Dim percorso As String = "''/percorso/del/file.gif''"
   Dim flHandle, i As Integer
+
   Dim i As Integer
 
   Dim st1 As Stream
 
   Dim st1 As Stream
 
    
 
    
 
   fl = Open percorso For Read
 
   fl = Open percorso For Read
  flHandle = fl.Handle
+
   
 
+
   GifFile1 = DGifOpenFileHandle(fl.Handle)
   GifFile1 = DGifOpenFileHandle(flHandle)
 
 
   If IsNull(GifFile1) Then Print "Impossibile ottenere il descrittore dell'immagine !"
 
   If IsNull(GifFile1) Then Print "Impossibile ottenere il descrittore dell'immagine !"
 
   
 
   

Versione delle 09:37, 3 dic 2014

La libreria GifLib consente di leggere e scrivere file immagine in formato GIF.


E' possibile ottenere anche alcune informazioni generali su un'immagine GIF.

Per poter utilizzare le risorse della libreria GifLib, utilizzeremo la libreria: libgif.so.4.1.6


Mostriamo un semplice esempio:

' GifFileType *DGifOpenFileHandle(int GifFileHandle)
' Update a New GIF file, given its file handle.
Private Extern DGifOpenFileHandle(FileHandle As Integer) As Pointer In "libgif:4.1.6"


Public Sub Main()

 Dim GifFile1, GifFile2 As Pointer
 Dim fl As File
 Dim percorso As String = "/percorso/del/file.gif"
 Dim i As Integer
 Dim st1 As Stream
 
  fl = Open percorso For Read
    
  GifFile1 = DGifOpenFileHandle(fl.Handle)
  If IsNull(GifFile1) Then Print "Impossibile ottenere il descrittore dell'immagine !"

  Print "== Dati generali dell'immagine ==\n"
  Print "File immagine: "; Null, percorso
  st1 = Memory GifFile1 For Read
  Read #st1, i
  Print "Larghezza: "; Null, i; " pixel"
  Read #st1, i
  Print "Altezza: "; Null, i; " pixel"
  Read #st1, i
  Print "Risol. colore: "; Null, i
  Seek #st1, 16
  Read #st1, GifFile2
  st1.Close

    st1 = Memory GifFile2 For Read
    Seek #st1, 4
    Read #st1, i
    Print "Bit per Pixel: "; Null, i; " bit"
   
' Va in chiusura:
  st1.Close
  fl.Close

End



Riferimenti