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 :

Problème exécution projet SDL


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Inscrit en
    Mai 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 10
    Par défaut Problème exécution projet SDL
    Bonjour à tous et merci pour tous ceux qui essaieront de m'aider
    Voilà je débute en SDL et j'aimerais réaliser un programme qui traite une image et affiche l'image originale et l'image obtenue en même temps j'ai écrit un programme mais il ne s'exécute pas. Pourriez vus m'aider s'il vous plait.
    le voici :

    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
     
    #include <stdlib.h>
    #include <stdio.h>
    #include <SDL/SDL.h>
     
    void pause();
    Uint32 obtenirPixel(SDL_Surface *, int , int );
    void definirPixel(SDL_Surface *, int , int , Uint32 );
     
    int main(int argc, char *argv[])
    {
        SDL_Surface *ecran = NULL, *imageDeFond = NULL,*imagetransf = NULL;
        SDL_Rect positionFond;
        SDL_Rect positiontransf;
        int x,y,h,w;
        Uint32 pixel;
     
        positionFond.x = 0;
        positionFond.y = 0;
        positiontransf.x = 500;
        positiontransf.y = 0;
     
        SDL_Init(SDL_INIT_VIDEO);
     
        ecran = SDL_SetVideoMode(1000, 600, 32, SDL_HWSURFACE);
        SDL_WM_SetCaption("Chargement d'images en SDL", NULL);
     
        imageDeFond = SDL_LoadBMP("rec1.bmp");
     
        SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
     
        SDL_LockSurface(imageDeFond); 
        for (y=0;y<imageDeFond->h;y++)
        {
            for (x=0;x<imageDeFond->w;x++)
            {
                pixel=obtenirPixel(imageDeFond,x,y);
                 /*et là le traitement*/
                definirPixel(imagetransf,x,y,pixel);
            }
        }
        SDL_UnlockSurface(imageDeFond);
        SDL_BlitSurface(imagetransf, NULL, ecran, &positionFond);
     
        SDL_Flip(ecran);
        pause();
     
        SDL_FreeSurface(imageDeFond);
        SDL_Quit();
     
        return EXIT_SUCCESS;
    }
     
    void pause()
    {
        int continuer = 1;
        SDL_Event event;
     
        while (continuer)
        {
            SDL_WaitEvent(&event);
            switch(event.type)
            {
                case SDL_QUIT:
                    continuer = 0;
            }
        }
    }
    Uint32 obtenirPixel(SDL_Surface *surface, int x, int y)
    {
     
        int nbOctetsParPixel = surface->format->BytesPerPixel;
     
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
     
     
        switch(nbOctetsParPixel)
        {
            case 1:
                return *p;
     
            case 2:
                return *(Uint16 *)p;
     
            case 3:
     
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                    return p[0] << 16 | p[1] << 8 | p[2];
                else
                    return p[0] | p[1] << 8 | p[2] << 16;
     
            case 4:
                return *(Uint32 *)p;
     
     
            default:
                return 0; 
        }
    }
     
    void definirPixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
    {
     
        int nbOctetsParPixel = surface->format->BytesPerPixel;
     
        Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * nbOctetsParPixel;
     
     
        switch(nbOctetsParPixel)
        {
            case 1:
                *p = pixel;
                break;
     
            case 2:
                *(Uint16 *)p = pixel;
                break;
     
            case 3:
     
                if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
                {
                    p[0] = (pixel >> 16) & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = pixel & 0xff;
                }
                else
                {
                    p[0] = pixel & 0xff;
                    p[1] = (pixel >> 8) & 0xff;
                    p[2] = (pixel >> 16) & 0xff;
                }
                break;
     
            case 4:
                *(Uint32 *)p = pixel;
                break;
        }
    }

  2. #2
    Membre habitué
    Inscrit en
    Mai 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 10
    Par défaut
    Il n'y a personne pur aider ?
    au fait le programme que j'ai ecrit juste avant sert à copier une image de fond dans une nouvelle image et d'afficher les deux

  3. #3
    Membre habitué
    Inscrit en
    Mai 2008
    Messages
    10
    Détails du profil
    Informations forums :
    Inscription : Mai 2008
    Messages : 10
    Par défaut
    Je vois que mon problème ne figure pas au box office mais je vous en prie aidez moi c'est urgent

  4. #4
    Membre émérite Avatar de orfix
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    707
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2007
    Messages : 707
    Par défaut
    Citation Envoyé par psyglobe Voir le message
    Je vois que mon problème ne figure pas au box office mais je vous en prie aidez moi c'est urgent
    Généralement cela veut dire que tu n'est pas au bon endroit !
    Tu aura certainement une réponse ici :
    Forum des développeurs > Technologies / Divers > Développement 2D, 3D et Jeux > APIs multimédia > SDL

    Bonne Chance ...

Discussions similaires

  1. Problème exécution projet Maven
    Par guns65 dans le forum Maven
    Réponses: 1
    Dernier message: 22/04/2013, 09h14
  2. Réponses: 0
    Dernier message: 04/11/2010, 14h38
  3. [macOS] Problème de compilation d'un projet SDL et Qt sur Mac OS X 10.6
    Par mak972 dans le forum Plateformes
    Réponses: 2
    Dernier message: 23/02/2010, 23h07
  4. Réponses: 4
    Dernier message: 18/05/2009, 01h43
  5. Problème exécutable SDL
    Par Coldmeat dans le forum SDL
    Réponses: 3
    Dernier message: 18/02/2008, 15h30

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