Jump to content
  • Advertisement
Sign in to follow this  
Xeeynamo

[DDraw-C++] Getting E_INVALIDARG during blitting 4BPP surfaces

This topic is 2538 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'm developing a graphical tool for a game that uses images pallettized. I'm using native Win32 API with GDI for drawing but, due to a lot of CPU usage, I decided to port the functions that uses GDI in DirectDraw.
The problem arises when I try to blit a surface in 4BPP format using RGB indexed colors, and the error that I receive from BltFast is E_INVALIDARG. The surface in 4BPP is called g_pDDSurfaceTest and I'm blitting it using BltFast from g_pDDSBack. The code that I'm using to create g_pDDSurfaceTest is:
DDSURFACEDESC ddsd;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize= sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd.dwWidth = width;
ddsd.dwHeight = height;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;
ddsd.ddpfPixelFormat.dwRGBBitCount = 4;
g_pDD->CreateSurface(&ddsd, &g_pDDSurfaceTest, NULL);

g_pDDSurfaceTest->Lock(NULL, &ddsd, DDLOCK_WRITEONLY, NULL);
memcpy(ddsd.lpSurface, data_img, width*height/2);
g_pDDSurfaceTest->Unlock(NULL);
LPDIRECTDRAWPALETTE pal;
g_pDD->CreatePalette(DDPCAPS_4BIT | DDPCAPS_INITIALIZE, (LPPALETTEENTRY)data_pal, &pal, NULL);
g_pDDSurfaceTest->SetPalette(pal);



and the code that I'm using to blit the surface that retreive me E_INVALIDARG is:

rc.left = 0; // RC values used only for testing
rc.right = 1;
rc.top = 0;
rc.bottom = 1;
dx_err = g_pDDSBack->BltFast(x, y, g_pDDSurfaceTest , &rc, DDBLTFAST_NOCOLORKEY);


When I use the image in 8BPP format using indexed colors or when I use 16/32BPP format, the BltFast return DD_OK so I'm sure that BltFast it's okay. Also I didn't receive any errors when I create the surface in 4BPP format, so I'm not understanding where is the problem exactly. With GDI I was using 4BPP without problems, creating the DC with CreateCompatibleDC(NULL), loading the bitmap in 4BPP using CreateDIBSection and change palettes in realtime (so without recreate a new HBITMAP only to change some colors) using SetDIBColorTable. I tried with DirectX SDK 7.0a and with DirectX SDK Feb_2010 and I receive the same error.
It's a DDraw bug? My videocard won't support that mode? WinNT 6.x doesn't support anymore 4bpp surfaces in DDraw Mode? Or simply I'm doing somethings wrong?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!