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 1: | Riga 1: | ||
La libreria '''GifLib''', scritta da Eric Steven Raymond, consente di leggere e scrivere file immagine in formato GIF. | La libreria '''GifLib''', scritta da Eric Steven Raymond, consente di leggere e scrivere file immagine in formato GIF. | ||
− | |||
E' possibile ottenere anche alcune informazioni generali su un'immagine 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. | + | Per poter utilizzare le risorse della libreria ''GifLib'', utilizzeremo la libreria condivisa: "''libgif.so.7.1.0'' " |
− | |||
Mostriamo un semplice esempio: | Mostriamo un semplice esempio: | ||
Riga 31: | Riga 29: | ||
<FONT Color=gray>' ''GifFileType *DGifOpenFileHandle(int GifFileHandle)'' | <FONT Color=gray>' ''GifFileType *DGifOpenFileHandle(int GifFileHandle)'' | ||
' ''Update a New GIF file, given its file handle.''</font> | ' ''Update a New GIF file, given its file handle.''</font> | ||
− | Private Extern DGifOpenFileHandle(FileHandle As Integer) As Pointer In "libgif: | + | Private Extern DGifOpenFileHandle(FileHandle As Integer) As Pointer In "libgif:7.1.0" |
Riga 42: | Riga 40: | ||
Dim st As Stream | Dim st As Stream | ||
− | + | fl = Open percorso For Read | |
− | + | GifFile1 = DGifOpenFileHandle(fl.Handle) | |
− | + | If GifFile1 == 0 Then Print "Impossibile ottenere il descrittore dell'immagine !" | |
− | + | Print "== Dati generali dell'immagine ==\n" | |
− | + | Print "File immagine: "; Null, percorso | |
− | + | st = 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 | |
− | + | st.Close | |
− | + | st = Memory GifFile2 For Read | |
− | + | Seek #st, 4 | |
− | + | Read #st, i | |
− | + | 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 | |
'''End''' | '''End''' | ||
− | |||
Versione delle 20:42, 30 nov 2021
La libreria GifLib, scritta da Eric Steven Raymond, 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 condivisa: "libgif.so.7.1.0 "
Mostriamo un semplice esempio:
The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ' GifFileType *DGifOpenFileHandle(int GifFileHandle) ' Update a New GIF file, given its file handle. Private Extern DGifOpenFileHandle(FileHandle As Integer) As Pointer In "libgif:7.1.0" 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 GifFile1 == 0 Then Print "Impossibile ottenere il descrittore dell'immagine !" Print "== Dati generali dell'immagine ==\n" Print "File immagine: "; Null, percorso st = 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 st.Close st = 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