Decouper un gos bmp en plusieur petit (par rapport au handle) ????

SnOOpss Messages postés 571 Date d'inscription samedi 3 avril 2004 Statut Membre Dernière intervention 5 décembre 2013 - 16 avril 2004 à 15:23
cs_JCDjcd Messages postés 1138 Date d'inscription mardi 10 juin 2003 Statut Membre Dernière intervention 25 janvier 2009 - 16 avril 2004 à 16:53
Bonjour tout le monde !!
Voila en fait pr un RPG mon moteur 2d utilise le procedure suivante
fichierbmp[0] = LoadABitmap("wall.bmp");
avec
HBITMAP LoadABitmap(LPSTR szFileName)
{
return (HBITMAP)LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
}
Et il me reste plus qu'a faire le tableau avec les handle des bitmaps. Le probleme c'est que ca m'oblige a avoir plusieurs bmp, donc ma solution a été d'essayer de faire un gros bmp pour que le programme decoupe plusieurs petit bmp dedans
ca aurait donné
gros = LoadABitmap("wall.bmp");
petit = getbmp(gros,0,0,32,32);
avec
HBITMAP getbmp(HBITMAP hSourceBitmap,int x,int y,int w,int h)
{
HBITMAP tmp;
tmp = CreateCompatibleBitmap(hSourceBitmap,w,h);

bool a = BitBlt(tmp, 0, 0,w,h,hSourceBitmap, x, y, SRCCOPY);
if (a==0) { ShowMessage(GetLastError());}
// avec la ligne precedente j'obtient l'erreur numero 87 sous W98 et 6 sous XP!!!!

return tmp;
}

j'ai aussi essayé
HBITMAP getbmp(HBITMAP hSourceBitmap,int x,int y,int w,int h)
{
HBITMAP tmp;
BITMAP SrcBitmap;

GetObject(hSourceBitmap, sizeof(BITMAP), (LPSTR)&SrcBitmap);
int planes = SrcBitmap.bmPlanes;
int pixel = SrcBitmap.bmBitsPixel;

tmp = CreateBitmap(w,h,planes,pixel,NULL);
bool a = BitBlt(tmp, 0, 0,w,h,hSourceBitmap, x, y, SRCCOPY);
if (a==0) { ShowMessage(GetLastError());}
// avec la ligne precedente j'obtient l'erreur numero 87 sous W98 et 6 sous XP!!!!
return tmp;
}
Et evidement aucun des 2 ne marchent !!
Si quelqu'un voyait mon erreur ...............

1 réponse

cs_JCDjcd Messages postés 1138 Date d'inscription mardi 10 juin 2003 Statut Membre Dernière intervention 25 janvier 2009 4
16 avril 2004 à 16:53
Heu BitBlt prend des HDC non des HBITMAP
regarde http://www.cppfrance.com/code.aspx?ID=21537
0
Rejoignez-nous