Jump to content
  • Advertisement

Archived

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

Dirk

D3DXLoadSurfaceFromFile

This topic is 6177 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 will use D3DXLoadSurfaceFromFile() to open an image from disk. But before I can use this I have to create the image with IDirect3DDevice8::CreateImageSurface() and so I will need the size (width & height) of the image. How can I receive this information? Thanks Dirk!

Share this post


Link to post
Share on other sites
Advertisement
Just check this code:

  
HRESULT hr;
HBITMAP hBitmap;
BITMAP Bitmap;

hBitmap = (HBITMAP)LoadImage(NULL,
PathName,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE |
LR_CREATEDDIBSECTION);

if(hBitmap == NULL)
{
SetError("Unable to load bitmap");
return E_FAIL;
}

GetObject(hBitmap,sizeof(BITMAP),&Bitmap);
DeleteObject(hBitmap);

hr = pDevice->CreateImageSurface(Bitmap.bmWidth,
Bitmap.bmHeight,
D3DFMT_X8R8G8B8,
ppSurface);

Share this post


Link to post
Share on other sites
Thanks KingsRevenge!

But I also like to use tga-images and your code is only useful for bitmap, right? I need from the imagefile: width, height, format (32bpp, 16 bpp)!

Thanks!

Share this post


Link to post
Share on other sites

  • 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!