Enregistrer une impression d'écran dans un fichier gif

cs_elodie92 Messages postés 1 Date d'inscription lundi 21 octobre 2002 Statut Membre Dernière intervention 21 octobre 2002 - 21 oct. 2002 à 20:26
cs_totodude Messages postés 24 Date d'inscription vendredi 19 mars 2004 Statut Membre Dernière intervention 6 avril 2004 - 6 avril 2004 à 14:35
Bonjour a tous,
Je dois enregistrer l'écran dans un fichier bmp puis le convertir en un fichier gif.
J'ai réussi a enregistrer l'encran en VB:
--------------------------------------------------------
Call keybd_event(vbKeySnapshot, 1, 0, 0)
SavePicture Clipboard.GetData(vbCFBitmap), "c:\screen.bmp"
DoEvents
--------------------------------------------------------
Mais je n'arrive pas a le traduir en C++ :-(
Et comment convertir ce fichier en gif apres ?
Merci d'avance pour vos réponses :-)

3 réponses

stephbb75 Messages postés 726 Date d'inscription mercredi 22 avril 2009 Statut Membre Dernière intervention 3 mars 2020
22 oct. 2002 à 09:09
Tu peut tester cela pour la capture :

#include "stdafx.h"
#include "toclip.h"
/****************************************************************
* toClipboard
* Inputs:
* CWnd * wnd: Window whose contents are to be sent
* to the clipboard
* BOOL FullWnd: TRUE for entire window,
* FALSE for client area
* Result: void
*
* Effect:
* Copies the contents of the client area or the window
* to the clipboard in CF_BITMAP format.
*****************************************************************/

void toClipboard(CWnd * wnd, BOOL FullWnd)
{
CDC dc;
if(FullWnd)
{ /* full window */
HDC hdc = ::GetWindowDC(wnd->m_hWnd);
dc.Attach(hdc);
} /* full window */
else
{ /* client area only */
HDC hdc = ::GetDC(wnd->m_hWnd);
dc.Attach(hdc);
} /* client area only */

CDC memDC;
memDC.CreateCompatibleDC(&dc);

CBitmap bm;
CRect r;
if(FullWnd)
wnd->GetWindowRect(&r);
else
wnd->GetClientRect(&r);

CString s;
wnd->GetWindowText(s);
CSize sz(r.Width(), r.Height());
bm.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);
CBitmap * oldbm = memDC.SelectObject(&bm);
memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY);

wnd->GetParent()->OpenClipboard();
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, bm.m_hObject);
CloseClipboard();

memDC.SelectObject(oldbm);
bm.Detach(); // make sure bitmap not deleted with CBitmap object
}

Pour la sauvegarde en gif, j'en est aucune idée !!

Steph
0
cs_Belt Messages postés 47 Date d'inscription jeudi 13 juin 2002 Statut Membre Dernière intervention 3 juillet 2006
24 nov. 2003 à 12:15
Si tu trouves la solution envoi moi un mail, je cherche aussi à faire ca mais j'y arrive pas !!
beltram82@yahoo.fr
MERCI BEAUCOUP :big)
0
cs_totodude Messages postés 24 Date d'inscription vendredi 19 mars 2004 Statut Membre Dernière intervention 6 avril 2004
6 avril 2004 à 14:35
salut tout le monde,

la fonction toClipboard ci dessus à l'air bien sympa, mais quel CWnd il faut passer en parametre ???

merci beaucoup

Cheers ;)
tom
0
Rejoignez-nous