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 19: | Riga 19: | ||
Dim percorso As String = "''/percorso/del/file.gif''" | Dim percorso As String = "''/percorso/del/file.gif''" | ||
Dim i As Integer | Dim i As Integer | ||
− | Dim | + | Dim st As Stream |
fl = Open percorso For Read | fl = Open percorso For Read | ||
Riga 29: | Riga 29: | ||
Print "File immagine: "; Null, percorso | Print "File immagine: "; Null, percorso | ||
st1 = Memory GifFile1 For Read | st1 = Memory GifFile1 For Read | ||
− | Read # | + | Read #st, i |
Print "Larghezza: "; Null, i; " pixel" | Print "Larghezza: "; Null, i; " pixel" | ||
− | Read # | + | Read #st, i |
Print "Altezza: "; Null, i; " pixel" | Print "Altezza: "; Null, i; " pixel" | ||
− | Read # | + | Read #st, i |
Print "Risol. colore: "; Null, i | Print "Risol. colore: "; Null, i | ||
− | Seek # | + | Seek #st, 16 |
− | Read # | + | Read #st, GifFile2 |
st1.Close | st1.Close | ||
st1 = Memory GifFile2 For Read | st1 = Memory GifFile2 For Read | ||
− | Seek # | + | Seek #st, 4 |
− | Read # | + | Read #st, i |
Print "Bit per Pixel: "; Null, i; " bit" | Print "Bit per Pixel: "; Null, i; " bit" | ||
<FONT Color=gray>' ''Va in chiusura:''</font> | <FONT Color=gray>' ''Va in chiusura:''</font> | ||
− | + | st.Close | |
fl.Close | fl.Close | ||
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 st 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 #st, i Print "Larghezza: "; Null, i; " pixel" Read #st, i Print "Altezza: "; Null, i; " pixel" Read #st, i Print "Risol. colore: "; Null, i Seek #st, 16 Read #st, GifFile2 st1.Close st1 = Memory GifFile2 For Read Seek #st, 4 Read #st, i Print "Bit per Pixel: "; Null, i; " bit" ' Va in chiusura: st.Close fl.Close End