Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

LECTURE D'UNE IMAGE GIF


Information sur la source

Catégorie :Graphique Niveau : Débutant Date de création : 12/12/2003 Date de mise à jour : 13/12/2003 21:37:34 Vu / téléchargé: 4 383 / 727

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

Description

Ce code se décompose en trois classes :
- Une classe permettant la lecture des images au format GIF de 2 à 256 couleurs. Et stocke l'image et la palette de couleurs dans des tableaux.
- Une classe utilisant ces tableaux pour placer l'image dans la classe TBitmap (Couleurs en 16, 24 ou 32 bits).
- Une classe utilisant ces tableaux pour placer l'image dans une surface DirectDraw (Couleurs en 16, 24 ou 32 bits).

De plus, dans l'archive, vous trouverez deux pages html expliquant le fonctionnement du programme.

Enfin, ce programme a été réalisé sous Borland C++. Comme c'est le seul compilateur dont je dispose, je ne sais pas si tout marche bien sur les autres. A tester...
 

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

signaler à un administrateur
Commentaire de sitesref le 17/12/2003 14:15:53

tu sais comment faire pour s'occuper des gifs animés ???

nn

signaler à un administrateur
Commentaire de lachtang le 19/12/2003 10:15:25

Les images des gifs animés se suivent dans le fichier. C'est à dire que le fichier se compose ainsi :
- Entête du fichier GIF (palette globale, écran global, ...)
- Bloc descripteur d'image de la première image
- Palette locale si elle existe
- Données compressées de la première image
- Bloc descripteur de la deuxième image
- Palette locale si elle existe
- Données compressées de la deuxième image
- Ainsi de suite jusqu'a la fin du fichier.

Je crois que ça répond à ta question. Et puisque tu poses cette question, je vais améliorer mon programme pour pouvoir lire toutes les images de ces types de fichier.

signaler à un administrateur
Commentaire de lachtang le 19/12/2003 14:02:21

Erratum :
En regardant de plus près, j'ai vu que j'ai fait une erreur. L'octet indiquant la fin du fichier GIF est le 0x3B.
De plus, Pour indiquer la fin d'une image et le début de la suivante on trouve le code 0x00.
Encore une chose, la temporisation de l'animation se trouve dans un bloc optionnelle (0x21) avec le premier code 0xF9 suivit de la longueur du bloc (4). Mais je ne connais pas la signification de la suite.

Si quelqu'un connaît...

signaler à un administrateur
Commentaire de BombStrike le 27/06/2004 19:08:19

voici ce que tu cherche :)




23. Graphic Control Extension.

      a. Description. The Graphic Control Extension contains parameters used
      when processing a graphic rendering block. The scope of this extension is
      the first graphic rendering block to follow. The extension contains only
      one data sub-block.

      This block is OPTIONAL; at most one Graphic Control Extension may precede
      a graphic rendering block. This is the only limit to the number of
      Graphic Control Extensions that may be contained in a Data Stream.

      b. Required Version.  89a.

      c. Syntax.

      7 6 5 4 3 2 1 0        Field Name                    Type
     +---------------+
  0  |               |       Extension Introducer          Byte
     +---------------+
  1  |               |       Graphic Control Label         Byte
     +---------------+

     +---------------+
  0  |               |       Block Size                    Byte
     +---------------+
  1  |     |     | | |       <Packed Fields>               See below
     +---------------+
  2  |               |       Delay Time                    Unsigned
     +-             -+
  3  |               |
     +---------------+
  4  |               |       Transparent Color Index       Byte
     +---------------+

     +---------------+
  0  |               |       Block Terminator              Byte
     +---------------+


      <Packed Fields>  =     Reserved                      3 Bits
                             Disposal Method               3 Bits
                             User Input Flag               1 Bit
                             Transparent Color Flag        1 Bit

            i) Extension Introducer - Identifies the beginning of an extension







                                                                        16


            block. This field contains the fixed value 0x21.

            ii) Graphic Control Label - Identifies the current block as a
            Graphic Control Extension. This field contains the fixed value
            0xF9.

            iii) Block Size - Number of bytes in the block, after the Block
            Size field and up to but not including the Block Terminator.  This
            field contains the fixed value 4.

            iv) Disposal Method - Indicates the way in which the graphic is to
            be treated after being displayed.

            Values :    0 -   No disposal specified. The decoder is
                              not required to take any action.
                        1 -   Do not dispose. The graphic is to be left
                              in place.
                        2 -   Restore to background color. The area used by the
                              graphic must be restored to the background color.
                        3 -   Restore to previous. The decoder is required to
                              restore the area overwritten by the graphic with
                              what was there prior to rendering the graphic.
                     4-7 -    To be defined.

            v) User Input Flag - Indicates whether or not user input is
            expected before continuing. If the flag is set, processing will
            continue when user input is entered. The nature of the User input
            is determined by the application (Carriage Return, Mouse Button
            Click, etc.).

            Values :    0 -   User input is not expected.
                        1 -   User input is expected.

            When a Delay Time is used and the User Input Flag is set,
            processing will continue when user input is received or when the
            delay time expires, whichever occurs first.

            vi) Transparency Flag - Indicates whether a transparency index is
            given in the Transparent Index field. (This field is the least
            significant bit of the byte.)

            Values :    0 -   Transparent Index is not given.
                        1 -   Transparent Index is given.

            vii) Delay Time - If not 0, this field specifies the number of
            hundredths (1/100) of a second to wait before continuing with the
            processing of the Data Stream. The clock starts ticking immediately
            after the graphic is rendered. This field may be used in
            conjunction with the User Input Flag field.

            viii) Transparency Index - The Transparency Index is such that when
            encountered, the corresponding pixel of the display device is not
            modified and processing goes on to the next pixel. The index is
            present if and only if the Transparency Flag is set to 1.

            ix) Block Terminator - This zero-length data block marks the end of







                                                                        17

            the Graphic Control Extension.

      d. Extensions and Scope. The scope of this Extension is the graphic
      rendering block that follows it; it is possible for other extensions to
      be present between this block and its target. This block can modify the
      Image Descriptor Block and the Plain Text Extension.

      e. Recommendations.

            i) Disposal Method - The mode Restore To Previous is intended to be
            used in small sections of the graphic; the use of this mode imposes
            severe demands on the decoder to store the section of the graphic
            that needs to be saved. For this reason, this mode should be used
            sparingly.  This mode is not intended to save an entire graphic or
            large areas of a graphic; when this is the case, the encoder should
            make every attempt to make the sections of the graphic to be
            restored be separate graphics in the data stream. In the case where
            a decoder is not capable of saving an area of a graphic marked as
            Restore To Previous, it is recommended that a decoder restore to
            the background color.

            ii) User Input Flag - When the flag is set, indicating that user
            input is expected, the decoder may sound the bell (0x07) to alert
            the user that input is being expected.  In the absence of a
            specified Delay Time, the decoder should wait for user input
            indefinitely.  It is recommended that the encoder not set the User
            Input Flag without a Delay Time specified.

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,296 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.