IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Décompression en jpeg


Sujet :

C

  1. #1
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut Décompression en jpeg
    bonjour,

    je cherche a Décompresser une image JPEG, j'ai trouver un bout de code, masi je ne saisi pas la nature des erreurs,

    voici le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
     :
    #include <stdio.h>
    #include "jpeglib.h"
    #include <setjmp.h>
     
    /*
     * jerror.c
     *
     * Copyright (C) 1991-1998, Thomas G. Lane.
     * This file is part of the Independent JPEG Group's software.
     * For conditions of distribution and use, see the accompanying README file.
     *
     * This file contains simple error-reporting and trace-message routines.
     * These are suitable for Unix-like systems and others where writing to
     * stderr is the right thing to do.  Many applications will want to replace
     * some or all of these routines.
     *
     * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile,
     * you get a Windows-specific hack to display error messages in a dialog box.
     * It ain't much, but it beats dropping error messages into the bit bucket,
     * which is what happens to output to stderr under most Windows C compilers.
     *
     * These routines are used by both the compression and decompression code.
     */
     
    /* this is not a core library module, so it doesn't define JPEG_INTERNALS */
    #include "jinclude.h"
    #include "jpeglib.h"
    #include "jversion.h"
    #include "jerror.h"
     
    #ifdef USE_WINDOWS_MESSAGEBOX
    #include <windows.h>
    #endif
     
    #ifndef EXIT_FAILURE		/* define exit() codes if not provided */
    #define EXIT_FAILURE  1
    #endif
     
     
    /*
     * Create the message string table.
     * We do this from the master message list in jerror.h by re-reading
     * jerror.h with a suitable definition for macro JMESSAGE.
     * The message table is made an external symbol just in case any applications
     * want to refer to it directly.
     */
     
    #ifdef NEED_SHORT_EXTERNAL_NAMES
    #define jpeg_std_message_table	jMsgTable
    #endif
     
    #define JMESSAGE(code,string)	string ,
     
    const char * const jpeg_std_message_table[] = {
    #include "jerror.h"
      NULL
    };
     
     
    /*
     * Error exit handler: must not return to caller.
     *
     * Applications may override this if they want to get control back after
     * an error.  Typically one would longjmp somewhere instead of exiting.
     * The setjmp buffer can be made a private field within an expanded error
     * handler object.  Note that the info needed to generate an error message
     * is stored in the error object, so you can generate the message now or
     * later, at your convenience.
     * You should make sure that the JPEG object is cleaned up (with jpeg_abort
     * or jpeg_destroy) at some point.
     */
     
    METHODDEF(void)
    error_exit (j_common_ptr cinfo)
    {
      /* Always display the message */
      (*cinfo->err->output_message) (cinfo);
     
      /* Let the memory manager delete any temp files before we die */
      jpeg_destroy(cinfo);
     
      exit(EXIT_FAILURE);
    }
     
     
    /*
     * Actual output of an error or trace message.
     * Applications may override this method to send JPEG messages somewhere
     * other than stderr.
     *
     * On Windows, printing to stderr is generally completely useless,
     * so we provide optional code to produce an error-dialog popup.
     * Most Windows applications will still prefer to override this routine,
     * but if they don't, it'll do something at least marginally useful.
     *
     * NOTE: to use the library in an environment that doesn't support the
     * C stdio library, you may have to delete the call to fprintf() entirely,
     * not just not use this routine.
     */
     
    METHODDEF(void)
    output_message (j_common_ptr cinfo)
    {
      char buffer[JMSG_LENGTH_MAX];
     
      /* Create the message */
      (*cinfo->err->format_message) (cinfo, buffer);
     
    #ifdef USE_WINDOWS_MESSAGEBOX
      /* Display it in a message dialog box */
      MessageBox(GetActiveWindow(), buffer, "JPEG Library Error",
    	     MB_OK | MB_ICONERROR);
    #else
      /* Send it to stderr, adding a newline */
      fprintf(stderr, "%s\n", buffer);
    #endif
    }
     
     
    /*
     * Decide whether to emit a trace or warning message.
     * msg_level is one of:
     *   -1: recoverable corrupt-data warning, may want to abort.
     *    0: important advisory messages (always display to user).
     *    1: first level of tracing detail.
     *    2,3,...: successively more detailed tracing messages.
     * An application might override this method if it wanted to abort on warnings
     * or change the policy about which messages to display.
     */
     
    METHODDEF(void)
    emit_message (j_common_ptr cinfo, int msg_level)
    {
      struct jpeg_error_mgr * err = cinfo->err;
     
      if (msg_level < 0) {
        /* It's a warning message.  Since corrupt files may generate many warnings,
         * the policy implemented here is to show only the first warning,
         * unless trace_level >= 3.
         */
        if (err->num_warnings == 0 || err->trace_level >= 3)
          (*err->output_message) (cinfo);
        /* Always count warnings in num_warnings. */
        err->num_warnings++;
      } else {
        /* It's a trace message.  Show it if trace_level >= msg_level. */
        if (err->trace_level >= msg_level)
          (*err->output_message) (cinfo);
      }
    }
     
     
    /*
     * Format a message string for the most recent JPEG error or message.
     * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX
     * characters.  Note that no '\n' character is added to the string.
     * Few applications should need to override this method.
     */
     
    METHODDEF(void)
    format_message (j_common_ptr cinfo, char * buffer)
    {
      struct jpeg_error_mgr * err = cinfo->err;
      int msg_code = err->msg_code;
      const char * msgtext = NULL;
      const char * msgptr;
      char ch;
      boolean isstring;
     
      /* Look up message string in proper table */
      if (msg_code > 0 && msg_code <= err->last_jpeg_message) {
        msgtext = err->jpeg_message_table[msg_code];
      } else if (err->addon_message_table != NULL &&
    	     msg_code >= err->first_addon_message &&
    	     msg_code <= err->last_addon_message) {
        msgtext = err->addon_message_table[msg_code - err->first_addon_message];
      }
     
      /* Defend against bogus message number */
      if (msgtext == NULL) {
        err->msg_parm.i[0] = msg_code;
        msgtext = err->jpeg_message_table[0];
      }
     
      /* Check for string parameter, as indicated by %s in the message text */
      isstring = FALSE;
      msgptr = msgtext;
      while ((ch = *msgptr++) != '\0') {
        if (ch == '%') {
          if (*msgptr == 's') isstring = TRUE;
          break;
        }
      }
     
      /* Format the message into the passed buffer */
      if (isstring)
        sprintf(buffer, msgtext, err->msg_parm.s);
      else
        sprintf(buffer, msgtext,
    	    err->msg_parm.i[0], err->msg_parm.i[1],
    	    err->msg_parm.i[2], err->msg_parm.i[3],
    	    err->msg_parm.i[4], err->msg_parm.i[5],
    	    err->msg_parm.i[6], err->msg_parm.i[7]);
    }
     
     
    /*
     * Reset error state variables at start of a new image.
     * This is called during compression startup to reset trace/error
     * processing to default state, without losing any application-specific
     * method pointers.  An application might possibly want to override
     * this method if it has additional error processing state.
     */
     
    METHODDEF(void)
    reset_error_mgr (j_common_ptr cinfo)
    {
      cinfo->err->num_warnings = 0;
      /* trace_level is not reset since it is an application-supplied parameter */
      cinfo->err->msg_code = 0;	/* may be useful as a flag for "no error" */
    }
     
     
    /*
     * Fill in the standard error-handling methods in a jpeg_error_mgr object.
     * Typical call is:
     *	struct jpeg_compress_struct cinfo;
     *	struct jpeg_error_mgr err;
     *
     *	cinfo.err = jpeg_std_error(&err);
     * after which the application may override some of the methods.
     */
     
    GLOBAL(struct jpeg_error_mgr *)
    jpeg_std_error (struct jpeg_error_mgr * err)
    {
      err->error_exit = error_exit;
      err->emit_message = emit_message;
      err->output_message = output_message;
      err->format_message = format_message;
      err->reset_error_mgr = reset_error_mgr;
     
      err->trace_level = 0;		/* default = no tracing */
      err->num_warnings = 0;	/* no warnings emitted yet */
      err->msg_code = 0;		/* may be useful as a flag for "no error" */
     
      /* Initialize message table pointers */
      err->jpeg_message_table = jpeg_std_message_table;
      err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1;
     
      err->addon_message_table = NULL;
      err->first_addon_message = 0;	/* for safety */
      err->last_addon_message = 0;
     
      return err;
    }
    premiere erreur, "erreur de syntaxe avant cinfo".
    je ne voit pas du tout quelle erreur il y a...
    ensuite , les METHODDEF(void) et le GLOBAL(struct jpeg_error_mgr *) de la fin me perturbe, qu'est dont ????
    et est indispensable de mettre tout ce code pour decoder en JPEG, ou pouvons nous faire plus simple.
    merci.

    Merci.

  2. #2
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    j'ai oublié de préciser, que la premiere ereur était a la ligne

    "error_exit (j_common_ptr cinfo) ".

  3. #3
    Modérateur
    Avatar de gangsoleil
    Homme Profil pro
    Manager / Cyber Sécurité
    Inscrit en
    Mai 2004
    Messages
    10 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Manager / Cyber Sécurité

    Informations forums :
    Inscription : Mai 2004
    Messages : 10 150
    Par défaut
    Bonjour,

    Est-ce que le type j_common_ptr est défini quelque part dans les fichiers h que vous incluez dans votre projet ?
    Si tel est bien le cas, est-ce que les ficheirs d'en-tête sont bien tous inclus ?
    "La route est longue, mais le chemin est libre" -- https://framasoft.org/
    Les règles du forum

  4. #4
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    Le précédent code, n'est plus d'actualité...
    J'ai corriger quelque erreur de ma part, et inclue les bon fichier.
    Par contre, il me reste une erreur, une fonction n'est pas défini, put_scanline_someplace;

    je pensai que ça aller de part avec les autre fonction de la libjpeg...

  5. #5
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut put_scanline_someplace
    comment est-ce possible ????*
    comment pourrai régler mon PB ???
    je cherche désespérement cette fonction sur le net, mais pas trouvé....

  6. #6
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par aziatedu13 Voir le message
    comment est-ce possible ????*
    comment pourrai régler mon PB ???
    je cherche désespérement cette fonction sur le net, mais pas trouvé....
    Je pense que c'est à toi de la créer, non ?

  7. #7
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut PUT_SCANLINE
    ben je ne croit pas....
    parce que dans plein de forum sur internet cette fonction est bien présente,
    et utilisé.
    Donc c'est pour cela que je ne comprend pas pourquoi du tout pourquoi elle n'est pas défini pour moi...
    Merci.

  8. #8
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par aziatedu13 Voir le message
    ben je ne croit pas....
    parce que dans plein de forum sur internet cette fonction est bien présente,
    et utilisé.
    Donc c'est pour cela que je ne comprend pas pourquoi du tout pourquoi elle n'est pas défini pour moi...
    Merci.
    un exemple ici :

    http://csourcesearch.net/package/asc...os/loadjpg.cpp

  9. #9
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    oui je l'ai trouver celui là d'exemple...
    mais il n'est pas commentait et il y a des dépendance énorme...
    faut que j'intégre des .h qu'il vienne de nul part, et je suis sur qu'il y a les 3/4 des ligne qui ne me servent pas.
    je ne voudorai pas surcharger mon code, masi allez a l'essentiel.
    cette exemple n'est pas du totu commentait pour la fonction put_scanline_someplace.

  10. #10
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    et puis je suis en C...et non en C++.

  11. #11
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    Et puis, je ne sait pas a quoi correspond la variable "agmp" dans la fonction put_scanline_someplace, et puis la variable bankparams.actpos = linenum * bankparams.linelen; // de uoi il s'agit???
    il y a bien une structure de défini de nom bankparams, mais c'est tout.
    j'ai copier tout le dossier de ce site, et mis les bonne dependance avec les bon repertoire.
    aucun résultat des erreurs partout.
    par xemple agpm inconnu.
    Merci.

  12. #12
    Membre confirmé
    Inscrit en
    Janvier 2007
    Messages
    170
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 170
    Par défaut
    rebonjour,

    j'ai trouver un code de sylvainmarechal a cette adresse
    "http://sylvainmarechal.chez-alice.fr/prog/unix-win32/tools/jpg2bmp.c"

    qui est se trouve parmis
    "http://sylvainmarechal.chez-alice.fr/prog/unix-win32/tools/tools.html"

    j'ai encore un soucis avec une fonction, jinit_write_bmp.
    elle est indéfini, et je ne sait pas du tout a quoi elle correspond.
    il n'y a aucune bibliothéque qui la déclare.

    Merci.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Décompression d'images jpeg en c#
    Par Kazushi38 dans le forum C#
    Réponses: 2
    Dernier message: 08/02/2014, 15h30
  2. [libjpeg] Décompression d'une image jpeg
    Par Matarc dans le forum Bibliothèques
    Réponses: 0
    Dernier message: 10/08/2011, 14h33
  3. décompresser des .zip
    Par Nico65 dans le forum C++
    Réponses: 3
    Dernier message: 30/11/2004, 14h51
  4. Réponses: 5
    Dernier message: 20/08/2002, 18h01
  5. comment réduire une image jpeg (taille x*y)
    Par don-diego dans le forum C
    Réponses: 4
    Dernier message: 14/07/2002, 20h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo