oRTEEZ
Messages postés81Date d'inscriptionvendredi 18 juillet 2003StatutMembreDernière intervention10 septembre 2003
-
13 août 2003 à 17:43
MAJCPP
Messages postés1Date d'inscriptionjeudi 14 août 2003StatutMembreDernière intervention14 août 2003
-
14 août 2003 à 17:43
Voila j'ai une fonction cense afficher un bitmp dans une List box en la resizant a la taille, j'ai passe la journee dessus et je craque, voila ma fonction:
void PrintBmp(HWND hWnd, char *filename)
{
HBITMAP hBmp;
BITMAP bm;
HDC hDC, prehDC;
RECT list;
int ximage, yimage; int xpos 0 , ypos 0;
int xlist, ylist;
float rapport;
//Charge mon image
hBmp=(HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
//transforme en bitmap pour recuperer la taille
GetObject (hBmp, sizeof(BITMAP), &bm);
ximage = bm.bmWidth;
yimage = bm.bmHeight;
//recupere les dimension de ma listbox
GetClientRect(hWnd, &list);
xlist = list.right;
ylist = list.bottom;
//Algo de resize
/* if (yimage > ylist)
{
rapport = abs(yimage/ximage);
yimage = ylist;
ximage = (ximage/rapport)-10;
}
*/
//Attribution de mon DC
hDC = GetDC(hWnd);
SelectObject(prehDC, hBmp);
oRTEEZ
Messages postés81Date d'inscriptionvendredi 18 juillet 2003StatutMembreDernière intervention10 septembre 2003 13 août 2003 à 17:57
Je crois bien que c'est cela mon probleme je ne sais pas comment mettre mon bitmap dans ce prehDC pour pourvoir ensuite le passer dans hDC grace a la fonction StretchBlt.
cs_aardman
Messages postés1905Date d'inscriptionmercredi 22 janvier 2003StatutMembreDernière intervention17 septembre 20123 13 août 2003 à 18:00
Salut,
CreateDC(...)
Je pense que si tu crée un DC ayant les meme carateristiques que hDC mais avec les dimentions de ton image ca serait mieux. Tu crée ton prehDC, tu y selectionne le bmp, et ensuite tu pourra copier prehDC dans hDC.
oRTEEZ
Messages postés81Date d'inscriptionvendredi 18 juillet 2003StatutMembreDernière intervention10 septembre 2003 13 août 2003 à 18:00
-------------------------------
Réponse au message :
-------------------------------
> Je crois bien que c'est cela mon probleme je ne sais pas comment mettre mon bitmap dans ce prehDC pour pourvoir ensuite le passer dans hDC grace a la fonction StretchBlt.
en fait j'ai mon SelectObject je pensais que cela marcherais mais apparement non...
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Salut,
> > Tu le sors d'ou ton prehDC ?
> > Tu selectionne ton hBmp a l'interieur de ce prehDC mais je ne vois pas la ligne ou tu le crée de DC.
> >
> >
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Voila j'ai une fonction cense afficher un bitmp dans une List box en la resizant a la taille, j'ai passe la journee dessus et je craque, voila ma fonction:
> > >
> > > void PrintBmp(HWND hWnd, char *filename)
> > > {
> > > HBITMAP hBmp;
> > > BITMAP bm;
> > > HDC hDC, prehDC;
> > > RECT list;
> > > int ximage, yimage;> > > int xpos 0 , ypos 0;
> > > int xlist, ylist;
> > > float rapport;
> > > //Charge mon image
> > > hBmp=(HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
> > >
> > > //transforme en bitmap pour recuperer la taille
> > > GetObject (hBmp, sizeof(BITMAP), &bm);
> > > ximage = bm.bmWidth;
> > > yimage = bm.bmHeight;
> > >
> > > //recupere les dimension de ma listbox
> > > GetClientRect(hWnd, &list);
> > > xlist = list.right;
> > > ylist = list.bottom;
> > >
> > > //Algo de resize
> > > /* if (yimage > ylist)
> > > {
> > > rapport = abs(yimage/ximage);
> > > yimage = ylist;
> > > ximage = (ximage/rapport)-10;
> > > }
> > > */
> > > //Attribution de mon DC
> > > hDC = GetDC(hWnd);
> > > SelectObject(prehDC, hBmp);
> > >
> > > //dessin de mon bitmap
> > > StretchBlt(hDC, 10,10,xlist,ylist, prehDC, 0,0, ximage, yimage, SRCCOPY);
> > > }
> > >
> > >
> > > La c'est la panique alors si une ame charitable pouvait se fendre d'une solution cela rejouirais mon petit coeur tout triste...
> > >
> > > MERkI
> >
>
Vous n’avez pas trouvé la réponse que vous recherchez ?
oRTEEZ
Messages postés81Date d'inscriptionvendredi 18 juillet 2003StatutMembreDernière intervention10 septembre 2003 13 août 2003 à 18:04
je comprend pas les argument qu'il faut placer dans CreateDC.
HDC CreateDC(
LPCTSTR lpszDriver, // pointer to string specifying driver name
LPCTSTR lpszDevice, // pointer to string specifying device name
LPCTSTR lpszOutput, // do not use; set to NULL
CONST DEVMODE *lpInitData
// pointer to optional printer data
);
cs_aardman
Messages postés1905Date d'inscriptionmercredi 22 janvier 2003StatutMembreDernière intervention17 septembre 20123 13 août 2003 à 18:30
Salut,
En fait il faut créer un DC en mémoire de la taille de ton bmp.
je pensais qu'on pouvais le faire avec CreateDC, mais c'est peut etre pas la bonne fonction.