Jump to content
  • Advertisement

Archived

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

Fireface

changing bit-count of a surface

This topic is 5728 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

Hi, I loaded a bitmap with the function "LoadBitmap" into an DirectDraw-Surface. However, the surface had an bit-depth of 24, and I just wanted 16 bpp. So I opened the help file and looked for some solution. After a few hours I had this code (which doesn''t work) :
	DDSURFACEDESC2	ddsdOld; // Alte Surface-Beschreibung
	DDSURFACEDESC2  ddsdNew; // Neue Surface-Beschreibung mit 16-Bit-Daten
	HRESULT		ddrval;

	// Alte Surface-Beschreibung laden
	ZeroMemory (&ddsdOld, sizeof (ddsdOld));
	ddsdOld.dwSize = sizeof (ddsdOld);
	ddrval = lpDDSurf->GetSurfaceDesc (&ddsdOld);
	if (ddrval !=  DD_OK)
	{
		return FALSE;
	};

	// Ändern der Daten für 16-Bit
	ZeroMemory (&ddsdNew, sizeof (ddsdNew));
	ddsdNew.dwSize = sizeof (ddsdNew);
	ddsdNew.dwFlags = DDSD_PITCH | DDSD_PIXELFORMAT;
	ddsdNew.ddpfPixelFormat = ddsdOld.ddpfPixelFormat;
	ddsdNew.ddpfPixelFormat.dwFlags = ddsdOld.ddpfPixelFormat.dwFlags | DDPF_RGB;
	ddsdNew.ddpfPixelFormat.dwRGBBitCount = 16; // Für 16 Bit
	ddsdNew.lPitch = ddsdOld.dwWidth*2; // 16Bit = 2 Byte = Breite * 2

	// Einstellen der neuen Surface-Beschreibung
	ddrval = lpDDSurf->SetSurfaceDesc (&ddsdNew, 0);
	if (ddrval != DD_OK)
	{
		MessageBox (NULL, "testwindow 1", NULL, MB_OK);
		return FALSE;
	}; 
	MessageBox (NULL, "testwindow 2", NULL, MB_OK);
 
I figured out, that "SetSurfaceDesc" doesn''t work correctly, because neighter testwindow1 nor testwindow2 has been showed. thanks for helping

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!