BltFast zeigt nichts an
-
Dieser Code soll ein kleines Bild anzeigen. Tut es aber nicht. Womit wir schon beim Problem wären. Mit Blt() klappt das wunderbar, aber mit BltFast will er mir nichts anzeigen:
class IMAGE { private: int w, h; bool transparent, loaded; LPDIRECTDRAWSURFACE7 lppdsImage; RECT rectImage; public: IMAGE() : w(0), h(0), transparent(false), loaded(false), lppdsImage(NULL) {} ~IMAGE(); bool init(LPCSTR file, int width, int height); void draw(int x, int y); void draw(int x, int y, int xstart, int xend, int ystart, int yend); void SetTransparent(DWORD high, DWORD low); }; bool IMAGE::init(LPCSTR source, int width, int height) { this->w = width; this->h = height; this->transparent = false; this->lppdsImage = DDLoadBitmap(lpDirectDraw, source, width, height); if(this->lppdsImage == NULL) { loaded = false; return false; } loaded = true; return true; } void IMAGE::SetTransparent(DWORD high, DWORD low) { this->transparent = true; AddColorKey(this->lppdsImage, high, low); } void IMAGE::draw(int x, int y) { SetRect(&(this->rectImage), x, y, x+this->w, y+this->h); if(transparent) lpddsBack->Blt(&rectImage, this->lppdsImage, NULL, DDBLT_WAIT | DDBLT_KEYSRC, NULL); else lpddsBack->Blt(&rectImage, this->lppdsImage, NULL, DDBLT_WAIT, NULL); } void IMAGE::draw(int x, int y, int xstart, int xend, int ystart, int yend) { RECT srcrect; SetRect(&srcrect, xstart, ystart, xend, yend); if(transparent) lpddsBack->BltFast((int)x, (int)y, lppdsImage, &srcrect, DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY); else lpddsBack->BltFast((int)x, (int)y, this->lppdsImage, &srcrect, DDBLTFAST_WAIT); } ////////////////////////////////////////////////////////////////////////////////////////////////////// Bilder[0].draw((int)y, (int)x); // klappt Bilder[0].draw((int)x, (int)y, 0, 100, 0, 100); // klappt nicht
-
Hi,
wie groß ist denn deine Quell-Surface?
-
200 mal 150 Pixel
-
Ok,
und ist sie im Videospeicher erstellt oder im Systemmem?
-
Ich glaube, dass ist gar nicht festgelegt. Ich lade das Bild ja mit DDLoadBitmap() :
DDLoadBitmap( IDirectDraw7* pdd, LPCSTR szBitmap, int dx, int dy) { HBITMAP hbm; BITMAP bm; DDSURFACEDESC2 ddsd; IDirectDrawSurface7 *pdds; // // Try to load the bitmap as a resource, if that fails, try it as a file // hbm = (HBITMAP) LoadImage(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, dx, dy, LR_CREATEDIBSECTION); if (hbm == NULL) hbm = (HBITMAP) LoadImage(NULL, szBitmap, IMAGE_BITMAP, dx, dy, LR_LOADFROMFILE | LR_CREATEDIBSECTION); if (hbm == NULL) return NULL; // // Get size of the bitmap // GetObject(hbm, sizeof(bm), &bm); // // Create a DirectDrawSurface for this bitmap // ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = bm.bmWidth; ddsd.dwHeight = bm.bmHeight; if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK) return NULL; DDCopyBitmap(pdds, hbm, 0, 0, 0, 0); DeleteObject(hbm); return pdds; }
-
Das solltest du aber festlegen.
This method works only on display memory surfaces and cannot clip when blitting. If you use this method on a surface with an attached clipper, the call fails, and the method returns DDERR_UNSUPPORTED.
-
An welcher Stelle muss ich das denn machen?
-
autocogito! Und die DX Debug Runtimes sind sicher auch nicht verkehrt.
Bye, TGGC (Pipe my World.)