Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ms291052

Loading A Bitmap To A Surface

This topic is 5495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this code to load a .bmp file onto a d3d surface but I can''t seem to find the rather massive memory leak in it. I''ve noticed that if I comment out the CreateOffscreen Plane it throws a NullReferenceException but I don''t get it! Here''s my code: int LoadBitmapToSurface(char* PathName, LPDIRECT3DSURFACE9* ppSurface, LPDIRECT3DDEVICE9 pDevice) { HRESULT r; HBITMAP hBitmap; BITMAP Bitmap; hBitmap = (HBITMAP)LoadImage(NULL, PathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); if(hBitmap == NULL) return E_FAIL; GetObject(hBitmap, sizeof(BITMAP), &Bitmap); DeleteObject(hBitmap); //r = pDevice->CreateImageSurface(Bitmap.bmWidth,Bitmap.bmHeight, D3DFMT_X8R8G8B8, ppSurface); r = pDevice->CreateOffscreenPlainSurface(Bitmap.bmWidth, Bitmap.bmHeight, D3DFMT_X8R8G8B8, D3DPOOL_SCRATCH, ppSurface, NULL); if(FAILED(r)) return E_FAIL; r = D3DXLoadSurfaceFromFile(*ppSurface, NULL, NULL, PathName, NULL, D3DX_FILTER_NONE, 0, NULL); if(FAILED(r)) return E_FAIL; return S_OK; }

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!