FontBitmap in laden in DDsurface array



  • Hi,
    Es soll eine FontBitmap in ein LPDIRECTDRAWSURFACE7 Array[128] geladen werden.
    Dazu habe ich nu die folgende Funktion geschrieben

    LPDIRECTDRAWSURFACE7 ati_Font[127];
    
    BOOL airFontInit(const char * bmp)
    {	LPDIRECTDRAWSURFACE7 FSurf;
    	if (airDD_Loadbmp_in_Surface2(bmp, &FSurf, TRUE) == FALSE)
    	{	MessageBox(g_hwnd, "Fehler: airDD_Loadbmp_in_Surface2(bmp,&FSurf, TRUE) == FALSE\n(airFontInit(const char * bmp))", "tjoar Pech!!", MB_OK);
    		return FALSE;}
    
    	DDSURFACEDESC2 ddsd;
    	DDCOLORKEY ddck;
    	LPSTR zRAM;
    	LPSTR qRAM;
    	LPSTR tmpqRAM;
    	int zBreite;
    	LPSTR col;
    	HRESULT hr;
    
    	ZeroMemory(&ddsd, sizeof(ddsd));
    	ddsd.dwSize = sizeof(ddsd);
    
    	FSurf->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
    	zBreite = ddsd.lPitch;
    	qRAM = (LPSTR)ddsd.lpSurface;
    	FSurf->Unlock(NULL);
    
    	ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
    	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    	ddsd.dwWidth = 16;
    	ddsd.dwHeight = 16;
    
    	for(int Reihe=0; Reihe < 8; Reihe++)
    	{	for(int i=0; i<16; i++)// i is Spalte
    		{	ati_Font[Reihe * 16 + i] = NULL;
    			hr = lpDD->CreateSurface(&ddsd, &ati_Font[Reihe * 16 + i], NULL);
    
    			if (FAILED(hr))
    			{	MessageBox(g_hwnd, "ERROR: lpDD->CreateSurface()\nairFontInit()", "Tjoar pech!!!", MB_OK);
    				return FALSE;}
    
    			tmpqRAM = qRAM;
    			tmpqRAM += Reihe * zBreite * 16;
    
    			ati_Font[Reihe * 16 + i]->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
    
    			zRAM = (LPSTR)ddsd.lpSurface;
    			for(int y=0; y < 16; y++)
    			{	memcpy(zRAM, tmpqRAM+i * 16, 16);
    				tmpqRAM += zBreite;
    				zRAM += ddsd.lPitch;
    			}//for
    
    			ati_Font[Reihe * 16 + i]->Unlock(NULL);
    		}//for anzahl
    	}//for Reihe
    
    	for(int k=0; k < 16; k++)
    	{	ati_Font[k]->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
    		col = (LPSTR)ddsd.lpSurface;
    		ddck.dwColorSpaceLowValue =(ULONG) col[0];
    		ddck.dwColorSpaceHighValue =(ULONG) col[0];
    		ati_Font[k]->SetColorKey(DDCKEY_SRCBLT, &ddck);
    		ati_Font[k]->Unlock(NULL);
    	}//for
    	return TRUE;
    }
    

    Und nun zu meinem Problem:
    Es wird nur die erste Reihe der Bitmap(256*256*8) geladen. Also geht der Array nur bis index 16. Was mache ch falsch?

    und noch eine zweite Frage neben bei:
    die Funktion airDD_Loadbmp_in_Surface2(...), die ich zuerst Aufrufe, createt die Surface, die ich übergebe und ladet die Bitmap hinein. Aber wieso muss ich den Operator "&" vor FSurf machen? FSurf ist doh schon ein LP, ein Pointer. Aber wenn ich es wegmache funzt nix mehr. Also wieso muss ich einen Pointer auf einen Poiner übergeben... 😕 ich find das irgendwie dämlich.

    Ich badanke mich schon mal für eine Antwort, falls jemnand sich die Mühe macht meine Fragen zu beantworten.



  • ÄÄhm also ihr braucht euch den coooth nicht anzugucken.
    Der Fehler ist mir beim Posten aufgefallen ;). Es liegt am colerkey den ih nur für die ersten 16 indexe gesetzt habe. Argh wie dumm, hab a stunden dran rumgefummel und nicht dran gedacht, das es am Colorkey liegen könnte argh.

    Aber Für eine Antwort der 2. Frage wär ich trotzdem dankbar.


Anmelden zum Antworten