Dessin

anubis52100 Messages postés 44 Date d'inscription vendredi 18 mars 2005 Statut Membre Dernière intervention 22 janvier 2007 - 6 juin 2005 à 13:43
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 - 6 juin 2005 à 19:16
bonjour je dessine en mfc dans un classe view.

voici mon code qui me sert a dessiner:

void CAView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if ((nFlags & MK_LBUTTON) == MK_LBUTTON)
{
//On recupere le Device
if(i==2)
{
CClientDC dc(this);
//Dessine une ligne entre le point précedant et le point actuel
dc.MoveTo(point.x-25,point.y);
dc.LineTo(point.x+25,point.y);
dc.LineTo(point.x+25,point.y+50);
dc.LineTo(point.x-25,point.y+50);
dc.LineTo(point.x-25,point.y);


}


if(i==3)
{
CClientDC dc(this);
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x,point.y+50);
}

if(i==4)
{
CClientDC dc(this);
//Dessine une ligne entre le point précedant et le point actuel
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x,point.y+50);
dc.LineTo(point.x,point.y+20);
dc.LineTo(point.x-5,point.y+20);
dc.LineTo(point.x+5,point.y+20);

}
if (i==5)
{
CClientDC dc(this);
//Dessine une ligne entre le point précedant et le point actuel
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x+50,point.y);
}
if(i==6)
{
CClientDC dc(this);
//Dessine une ligne entre le point précedant et le point actuel
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x+50,point.y);
dc.LineTo(point.x+20,point.y);
dc.LineTo(point.x+20,point.y-5);
dc.LineTo(point.x+20,point.y+5);
}
if(i==7)
{
CClientDC dc(this);
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x+50,point.y);
dc.LineTo(point.x-50,point.y);
dc.LineTo(point.x+50,point.y+1);
dc.LineTo(point.x-51,point.y+1);

// dc.LineTo(point.x+20,point.y+5);

CClientDC dc2(this);
dc2.MoveTo(point.x,point.y+5);
dc2.LineTo(point.x+50,point.y+5);
dc2.LineTo(point.x-50,point.y+5);
dc2.LineTo(point.x+50,point.y+6);
dc2.LineTo(point.x-51,point.y+6);
}
if (i==8)
{
CClientDC dc(this);
//Dessine une ligne entre le point précedant et le point actuel
dc.MoveTo(point.x-25,point.y);
dc.LineTo(point.x+25,point.y);
dc.LineTo(point.x+25,point.y+50);
dc.LineTo(point.x-25,point.y+50);
dc.LineTo(point.x-25,point.y);


CClientDC dc2(this);
dc2.MoveTo(point.x-20,point.y+5);
dc2.LineTo(point.x+20,point.y+5);
dc2.LineTo(point.x+20,point.y+45);
dc2.LineTo(point.x-20,point.y+45);
dc2.LineTo(point.x-20,point.y+5);
}
if(i==9)
{
CClientDC dc(this);
dc.MoveTo(point.x,point.y);
dc.LineTo(point.x,point.y-50);
dc.LineTo(point.x,point.y-20);
dc.LineTo(point.x-5,point.y-15);
dc.LineTo(point.x,point.y-20);
dc.LineTo(point.x+5,point.y-15);

}
i=0;
}

CView::OnLButtonDown(nFlags, point);
}

mon probleme est que je souhaiterai enregistrer limage que j'ai dessiner dans ma fenetre mais je ne trouve pas de fonction qui marche.

merci !

3 réponses

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
6 juin 2005 à 13:57
Tu peux facilement la mettre dans une variable HBITMAP (ou CBitmap sous
MFC), et créant un DC mémoire (memdc = CreateCompatibleDC(dc)) et en y
séléctionnant une bitmap (hbmp = CreateCompatibleBitmap(dc);
SelectObject(memdc, bmp)), puis en faisant un BitBlt de dc vers memdc.

Quand tu enregistrer, ca veut dire dans un fichier?
0
anubis52100 Messages postés 44 Date d'inscription vendredi 18 mars 2005 Statut Membre Dernière intervention 22 janvier 2007
6 juin 2005 à 18:03
je maîtrise pas du tout ces fonction la peut tu m'expliquer comment tu fait pour enrigistrer dans un fichier bmp. aurai tu un exemple ou une application merci.
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
6 juin 2005 à 19:16
Enregistrer dans un bmp je sais pas faire exactement

Cette source devrait t'aider: http://www.cppfrance.com/code.aspx?id=11128
0
Rejoignez-nous