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

Windows Discussion :

[api windows]envoyer une BMP par une socket


Sujet :

Windows

  1. #1
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut [api windows]envoyer une BMP par une socket
    Bonjours, j'essaie d'envoyer une image capturée a l'aide de l'api windows.
    j'arrive a envoyer un fichier ouvert, mais, lorsqeu j'essaie d'envoyer une image capturée a l'aide d'un DC, je n'y arrive pas.
    voici mon 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
    //capture de l'image affichée a l'ecran
    	HDC imageCapturee;
    	imageCapturee = CreateDC("DISPLAY", NULL, NULL, NULL); 
    
    //initialisation de vars...
    	int largeur, longueur;
        wxUint32 nbPixel;
    	largeur =  GetDeviceCaps(imageCapturee, HORZRES); 
    	longueur = GetDeviceCaps(imageCapturee, VERTRES);
    	HBITMAP BmpResutante ;
    
    //on crée la bitmap
        BmpResutante = CreateCompatibleBitmap(imageCapturee, largeur, longueur); 
    //je sait pas si il faut le faire??
        SelectObject(imageCapturee, BmpResutante);
        nbPixel =(wxUint32) largeur * longueur;
    
    //inutil dans cet exemple...
    	sockBaseImg->SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
    	sockBaseImg->Write(&nbPixel, 4);
    	sockBaseImg->Write(BmpResutante->bmBits , nbPixel);//c'est la que ca ne marche pas...
    Mon probleme est le suivant :
    ce type est le suivant
    HBITMAP Handle to a bitmap.
    This type is declared in WinDef.h as follows : typedef HANDLE HBITMAP;
    c'est donc un handle, etant un noob, je ne sait pas comment acceder a la donnée elle meme (le tableau de bit).
    je suis allé voir du coté du type bitmap, mais jen'ai rien trouvé d'interressant...


  2. #2
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    CreateCompatibleDC() pour un DC en mémoire.
    CreateDIBSection(); pour un bitmap dont tu as accès à la mémoire
    BitBlt() pour copier l'image depuis Windows vers ton bitmap...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  3. #3
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    Merci de ta reponse, j'ai regardé la doc de "CreateDIBSection()" sur MSDN, j'en suis au meme pb qu'une des solutions que j'avait trouvé :
    parmis ses parametres, il y a :
    CONST BITMAPINFO *pbmi, // bitmap data
    si je regarde la doc sur bitmapinfo :
    typedef struct tagBITMAPINFO {
    BITMAPINFOHEADER bmiHeader;
    RGBQUAD bmiColors[1];
    } BITMAPINFO, *PBITMAPINFO;
    il me faut un bitmapinfoheader, la doc dessus dit :
    typedef struct tagBITMAPINFOHEADER{
    DWORD biSize;
    LONG biWidth;
    LONG biHeight;
    WORD biPlanes;
    WORD biBitCount;
    DWORD biCompression;
    DWORD biSizeImage;
    LONG biXPelsPerMeter;
    LONG biYPelsPerMeter;
    DWORD biClrUsed;
    DWORD biClrImportant;
    } BITMAPINFOHEADER, *PBITMAPINFOHEADER;
    et : "biBitCount " et d'autres options me posent pb : je ne sait pas comment retrouver ces info depuis le systeme...

    puis-je re-utiliser des info créées a l'aide d'un create compatible bitmap?


    je suis desolé suis je pose des questions trop precises, mais je suis en retard pour rendre ce log qui doit me servir pour l'examen de mon BTS, et sur MSDN je suis assez paumé...

  4. #4
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    en faisant une recherche, j'ai trouvé des topics en repport, je regarde :
    http://www.developpez.net/forums/viewtopic.php?t=433162

  5. #5
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    j'ai le PB suivant au niveau de BitBlt() :
    cannot convert `HBITMAP__**' to `HDC__*' for argument `1' to `BOOL BitBlt(HDC__*, int, int, int, int, HDC__*, int, int, DWORD)'
    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
    	HDC imageCapturee;
    	imageCapturee = CreateDC("DISPLAY", NULL, NULL, NULL); 
    	int largeur, longueur;
        wxUint32 nbPixel;
    	largeur =  GetDeviceCaps(imageCapturee, HORZRES); 
    	longueur = GetDeviceCaps(imageCapturee, VERTRES);
    	
    BITMAPINFO bmInfo; 
    memset(&bmInfo.bmiHeader, 0, sizeof(BITMAPINFOHEADER)); 
    bmInfo.bmiHeader.biSize         = sizeof(BITMAPINFOHEADER); 
    bmInfo.bmiHeader.biWidth        = largeur;
    bmInfo.bmiHeader.biHeight       = longueur; 
    bmInfo.bmiHeader.biPlanes       = 1; 
    bmInfo.bmiHeader.biBitCount     = 32; 
    LPVOID pBit32; 
    HBITMAP BmpResutante = CreateDIBSection(0, &bmInfo, DIB_RGB_COLORS, &pBit32, NULL, 0); 
    
    if ( !BitBlt(
      &BmpResutante, // handle to destination DC   <---erreure
      0,  // x-coord of destination upper-left corner
      0,  // y-coord of destination upper-left corner
      largeur,  // width of destination rectangle
      longueur, // height of destination rectangle
      imageCapturee,  // handle to source DC
      0,   // x-coordinate of source upper-left corner
      0,   // y-coordinate of source upper-left corner
      "BLACKNESS"  // raster operation code
      &#41;;		
      &#41;

  6. #6
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    auto reponse :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    int GetDIBits&#40;
      HDC hdc,           // handle to DC
      HBITMAP hbmp,      // handle to bitmap
      UINT uStartScan,   // first scan line to set
      UINT cScanLines,   // number of scan lines to copy
      LPVOID lpvBits,    // array for bitmap bits
      LPBITMAPINFO lpbi, // bitmap data buffer
      UINT uUsage        // RGB or palette index
    &#41;;
    semble etre la solution appropriée. Mais elle copie dans le mauvais sens : bmp vers DC, alors que je veut faire une copie de DC vers BMP...

  7. #7
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    SetDIBits() ?

    Ou bien, CreateCompatibleDC(), SelectObject(), et un BitBlt() de DC à DC...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  8. #8
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    vi, je pensait utiliser SetDIBits mais :
    SetDIBits Sets the pixels in a bitmap using color data from a DIB.
    ca ne me semble pas etre ce que je vaut faire...
    je vait donc tester mais surment me tourner vers
    CreateCompatibleDC(), SelectObject(), et un BitBlt() de DC à DC...
    mais, car il faut un mais : Pourrais-je acceder a l'adresse ou est stockée ma BMP, afin de l'envoyer par reseau? (il faut lire ceci avec une voix super grave!)

  9. #9
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Bien sûr!

    Regarde ton code initial : L'erreur, c'est que tu essayais de faire le bitblt directment sur le HBITMAP alors que bitblt demande un HDC.

    Alors, tu as juste à faire
    CreateCompatibleDC() pour créer un DC compatible avec le DC source
    SelectObject() pour sélectionner BmpResutante dans nouveau DC (n'oublie pas de mémoriser le HBITMAP de l'ancienne image)

    BitBlt();

    GdiFlush() (Nécessaire quand on veut tripoter les données binaires du bitmap: pour modifier *pBit32)

    Et quand tu n'as plus besoin du DC :
    SelectObject() pour remettre l'ancien bitmap dans le DC
    DeleteDC()

    Après ça, normalement, pBit32 est toujours valide: tu peux récupérer les données.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  10. #10
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    lors d'une de mes errances aigries, mon coeur rance a recueilli, cette url, et il m'a sussuré "quelle merveille", depuis, je me noit dans paresse et oseille (heu*... groseille, groseille :'( )

    voila, la solution est ici, je pense

    merci all

  11. #11
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    le retours du jet d'ail :

    je me trouve fort depourvu : aucune piste ne fut venue!

    en effet, je capture le bitmap, de facon classe, je pense (copier/coller ;p )

    mais, je n'arrive pas a l'envoyer par le reseau...
    voici ma capture :
    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
    HBITMAP Maclasse&#58;&#58;snapshoot&#40;&#41;
    &#123;
    
        int nScreenWidth = GetSystemMetrics&#40;SM_CXSCREEN&#41;;
        int nScreenHeight = GetSystemMetrics&#40;SM_CYSCREEN&#41;;
        HWND hDesktopWnd = GetDesktopWindow&#40;&#41;;
        HDC hDesktopDC = GetDC&#40;hDesktopWnd&#41;;
        HDC hCaptureDC = CreateCompatibleDC&#40;hDesktopDC&#41;;
        HBITMAP hCaptureBitmap =CreateCompatibleBitmap&#40;hDesktopDC, 
            nScreenWidth, nScreenHeight&#41;;
        SelectObject&#40;hCaptureDC,hCaptureBitmap&#41;; 
        BitBlt&#40;hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY&#41;;     
        ReleaseDC&#40;hDesktopWnd,hDesktopDC&#41;;
        DeleteDC&#40;hCaptureDC&#41;;
        return hCaptureBitmap; 
    
    &#125;
    et voici mon envoie par reseau :
    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
    void Maclasse&#58;&#58;sendImg&#40;&#41;
    &#123;
    	//on envoir une image
    HBITMAP Bmp;
    	Bmp = snapshoot&#40;&#41;;
        	//	 memoLog->AppendText&#40;_&#40;"on a raté la copie de bitblit"&#41;&#41;;	
        //if &#40;!Bmp&#41; 
          //  memoLog->AppendText&#40;_&#40;"Erreure lors de la creation del'image!"&#41;&#41;;
            
    	HDC DCecran;
    	DCecran = CreateDC&#40;"DISPLAY", NULL, NULL, NULL&#41;; 
    	int largeur, longueur;
    	largeur =  GetDeviceCaps&#40;DCecran, HORZRES&#41;; 
    	longueur = GetDeviceCaps&#40;DCecran, VERTRES&#41;;        
            
            
        wxUint32 nbPixel = &#40;wxUint32&#41; largeur * longueur;
        int *bufferImage = new int&#91;nbPixel&#93;;
        wxString temp; 
        temp<<nbPixel; 
        memoLog->AppendText&#40;_&#40;"Envoie de la taille du fichier &#58; "&#41;&#41;;
    	memoLog->AppendText&#40;temp&#41;;
        memoLog->AppendText&#40;_&#40;"\n"&#41;&#41;;
    	memoLog->AppendText&#40;_&#40;"Envoie du fichier &#58; "&#41;&#41;;
    	sockBaseImg->SetNotify&#40;wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG&#41;;
    	sockBaseImg->Write&#40;&nbPixel, 4&#41;;
    	sockBaseImg->Write&#40;Bmp , nbPixel&#41;;
    	if &#40; sockBaseImg->Error&#40;&#41; &#41; 
     	   	   memoLog->AppendText&#40;_&#40;"Erreure lors de l'nevoie de l'image\n"&#41;&#41;;
    	memoLog->AppendText&#40;_&#40;"FIN\n\n"&#41;&#41;;
    	sockBaseImg->SetNotify&#40;wxSOCKET_LOST_FLAG | wxSOCKET_OUTPUT_FLAG | wxSOCKET_INPUT_FLAG&#41;;
    
    &#125;
    bon, le code n'est pas une merveille d'optimisation, masi la n'est pas le pb.
    en effet, je sait que mon code est sensé focntionner dans l'absolut, car il fonctionne pour l'envoie d'un fichier...
    la seule difference, est que le fichier etait stocké dans unt albeau, et la la bmp, dans une strucure.
    j'ai pas mal parcouru msdn, pour en arriver a ce copier coller minable, mais, je n'ai jamais reussi a vraiment apprehender la structure de ces maudites bmp!

    si je pouvait avoir un poil d'aide (vivi! ca existe!)

  12. #12
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    euh... Je ne suis pas sûr que tu puisses envoyer quoi que ce soit, là...

    Déjà, tu utilises une CompatibleBitmap (DDB) au lieu d'une Device-Independent-Bitmap(DIB) : Tu n'as donc pas accès aux données binaires du bitmap...

    Essaie ceci: Storing an Image
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  13. #13
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    merci bezaucoup a toi!
    ca a l'air de marcher, voici le code, si quelqu'un en a besoin...
    (je nie toute responsabilitée quand a la non presence de bug, j'ai tout fait pour...)
    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
    	//on envoir une image
    	HBITMAP Bmp;
    	Bmp = snapshoot&#40;&#41;;
    	PBITMAPINFO infoStruct;
    	infoStruct = CreateBitmapInfoStruct&#40;Bmp&#41;  ; 
        	//	 memoLog->AppendText&#40;_&#40;"on a raté la copie de bitblit"&#41;&#41;;	
        //if &#40;!Bmp&#41; 
          //  memoLog->AppendText&#40;_&#40;"Erreure lors de la creation del'image!"&#41;&#41;;
            
    	HDC DCecran;
    	DCecran = CreateDC&#40;"DISPLAY", NULL, NULL, NULL&#41;; 
    	int largeur, longueur;
    	largeur =  GetDeviceCaps&#40;DCecran, HORZRES&#41;; 
    	longueur = GetDeviceCaps&#40;DCecran, VERTRES&#41;;        
        
    	LPBYTE bufferImage;              // memory pointer 
    	PBITMAPINFOHEADER pbih; 
    	pbih = &#40;PBITMAPINFOHEADER&#41; infoStruct; 
        bufferImage = &#40;LPBYTE&#41; GlobalAlloc&#40;GMEM_FIXED, pbih->biSizeImage&#41;;
        if &#40;!GetDIBits&#40;DCecran, Bmp, 0, &#40;WORD&#41; pbih->biHeight, bufferImage, infoStruct, 
            DIB_RGB_COLORS&#41;&#41; 
        &#123;
            memoLog->AppendText&#40;_&#40;"erreuer de création du BMP"&#41;&#41;;
        &#125;
        
        wxUint32 nbPixel = &#40;wxUint32&#41; largeur * longueur;
        //int *bufferImage = new int&#91;nbPixel&#93;;
        wxString temp; 
        temp<<nbPixel; 
        memoLog->AppendText&#40;_&#40;"Envoie de la taille du fichier &#58; "&#41;&#41;;
    	memoLog->AppendText&#40;temp&#41;;
        memoLog->AppendText&#40;_&#40;"\n"&#41;&#41;;
    	memoLog->AppendText&#40;_&#40;"Envoie du fichier &#58; "&#41;&#41;;
    	sockBaseImg->SetNotify&#40;wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG&#41;;
    	sockBaseImg->Write&#40;&nbPixel, 4&#41;;
    	sockBaseImg->Write&#40;bufferImage , nbPixel&#41;;
    	if &#40; sockBaseImg->Error&#40;&#41; &#41; 
     	   	   memoLog->AppendText&#40;_&#40;"Erreure lors de l'nevoie de l'image\n"&#41;&#41;;
    	memoLog->AppendText&#40;_&#40;"FIN\n\n"&#41;&#41;;
    	sockBaseImg->SetNotify&#40;wxSOCKET_LOST_FLAG | wxSOCKET_OUTPUT_FLAG | wxSOCKET_INPUT_FLAG&#41;;
    + un code deja collé plus haut, plus celui ci dessous, tpus deux copié collés de msdn...
    =>
    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
    PBITMAPINFO vncPeuThreadeFrm&#58;&#58;CreateBitmapInfoStruct&#40;HBITMAP hBmp&#41;    
    &#123;
    //maintenant, on va créer une vrai bitmap.
        BITMAP bmp; 
        PBITMAPINFO pbmi; 
        WORD    cClrBits; 
    
        // Retrieve the bitmap color format, width, and height. 
        if &#40;!GetObject&#40;hBmp, sizeof&#40;BITMAP&#41;, &#40;LPSTR&#41;&bmp&#41;&#41; 
             memoLog->AppendText&#40;_&#40;"erreuer"&#41;&#41;;
    
        // Convert the color format to a count of bits. 
        cClrBits = &#40;WORD&#41;&#40;bmp.bmPlanes * bmp.bmBitsPixel&#41;; 
        if &#40;cClrBits == 1&#41; 
            cClrBits = 1; 
        else if &#40;cClrBits <= 4&#41; 
            cClrBits = 4; 
        else if &#40;cClrBits <= 8&#41; 
            cClrBits = 8; 
        else if &#40;cClrBits <= 16&#41; 
            cClrBits = 16; 
        else if &#40;cClrBits <= 24&#41; 
            cClrBits = 24; 
        else cClrBits = 32; 
    
        // Allocate memory for the BITMAPINFO structure. &#40;This structure 
        // contains a BITMAPINFOHEADER structure and an array of RGBQUAD 
        // data structures.&#41; 
    
         if &#40;cClrBits != 24&#41; 
             pbmi = &#40;PBITMAPINFO&#41; LocalAlloc&#40;LPTR, 
                        sizeof&#40;BITMAPINFOHEADER&#41; + 
                        sizeof&#40;RGBQUAD&#41; * &#40;1<< cClrBits&#41;&#41;; 
    
         // There is no RGBQUAD array for the 24-bit-per-pixel format. 
    
         else 
             pbmi = &#40;PBITMAPINFO&#41; LocalAlloc&#40;LPTR, 
                        sizeof&#40;BITMAPINFOHEADER&#41;&#41;; 
    
        // Initialize the fields in the BITMAPINFO structure. 
    
        pbmi->bmiHeader.biSize = sizeof&#40;BITMAPINFOHEADER&#41;; 
        pbmi->bmiHeader.biWidth = bmp.bmWidth; 
        pbmi->bmiHeader.biHeight = bmp.bmHeight; 
        pbmi->bmiHeader.biPlanes = bmp.bmPlanes; 
        pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel; 
        if &#40;cClrBits < 24&#41; 
            pbmi->bmiHeader.biClrUsed = &#40;1<<cClrBits&#41;; 
    
        // If the bitmap is not compressed, set the BI_RGB flag. 
        pbmi->bmiHeader.biCompression = BI_RGB; 
    
        // Compute the number of bytes in the array of color 
        // indices and store the result in biSizeImage. 
        // For Windows NT, the width must be DWORD aligned unless 
        // the bitmap is RLE compressed. This example shows this. 
        // For Windows 95/98/Me, the width must be WORD aligned unless the 
        // bitmap is RLE compressed.
        pbmi->bmiHeader.biSizeImage = &#40;&#40;pbmi->bmiHeader.biWidth * cClrBits +31&#41; & ~31&#41; /8
                                      * pbmi->bmiHeader.biHeight; 
        // Set biClrImportant to 0, indicating that all of the 
        // device colors are important. 
         pbmi->bmiHeader.biClrImportant = 0; 
         return pbmi; 
     &#125;
    ps : GetDIBits() => il le fallait bien

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 18/06/2009, 15h09
  2. Réponses: 3
    Dernier message: 07/08/2008, 13h19
  3. Réponses: 4
    Dernier message: 31/10/2007, 20h27
  4. masquer une partie d'une vidéo par une banniere
    Par lezabour dans le forum Général Conception Web
    Réponses: 1
    Dernier message: 16/10/2006, 16h47
  5. Réponses: 11
    Dernier message: 05/10/2006, 13h20

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