Archived

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

PSI_Orion

DX->BMP Screen Capture Color Conversions

Recommended Posts

OK, I'm hitting my head against a brick wall and I've read many a post here but none have answered my question. What I need to do (and I'm hoping this will be fairly simple) is to get a screen capture of a Direct3D game (actually, Diablo II: LoD) and get the screen capture to look the same as the screen in the game. I have NO clue how to do this - I've tried 3 different screen capture programs, all which produce the same results. All I need to do is to be able to get one color in the game to be the same in the screen shot then I can do the rest. But it's getting that first color correct that's bugging me (in more ways than one). Basically, what I'm getting in the game is a nice bright yellow, but in the screen capture it's more like a pinky orange (a real nice pastel color but not what I want). I have no clue whether this has anything to do with D3DCOLOR or Color Keys as I've never done any programming using DirectX. I use Visual C++6 (MFC) to program and I'm desperate to get this sorted! Feel free to email me [psiss@iname.com] or just post a reply - any help GLADLY received! TTFN! Chris. ******************* PetSound Industries ******************* Always trying to help. Will always try to deliver. Edited by - PSI_Orion on August 14, 2001 2:24:01 AM Edited by - PSI_Orion on August 14, 2001 2:25:09 AM

Share this post


Link to post
Share on other sites
I''m kind of unclear as to whether you are writing a program to take screen captures or whether you are just trying to get a screen shot.

Writing a program would be a bit difficult as I don''t think DirectX is very nice about sharing screen resources/surfaces.

Taking a screenshot to a file *should* be easy. The program probably does it itself with a key (try F12 or something). If this fails, press ALT-PrintScrn while in the game. Then quite and load up Paint or a similar program. Select Edit | Paste and you should be in business.

However, if your colors are still coming out incorrectly, make sure that the color depth of the program, the color depth of your image (in the paint program) and the color depth of your desktop are all the same (either 16bit or 32bit). This should solve any problems that way.

Hope that helps.

Share this post


Link to post
Share on other sites
Thanks for the reply.

What I''m doing is writing a program that enables the colors within the program to be user selectable. It works as a companion to another program which actually does the changes but this one basically allows the user to select their desired colors.

Is there any way I can find out what depth the DirectX game is in? The game is Dibalo 2: Lord Of Destruction and I''m running it with it''s highest available graphic settings. If I change these graphic settings in the game (say to a lower detail) the colors in question remain the same.

I''ve tried adjusting gama and such but to no avail. I''m stumped as to why I get the differences.

I will try running my desktop in 32 bit, but I find it hard to believe that a 3D game would run at such a high resolution (800 x 600) with that depth as a lot of machines wouldn''t be able to habndle it.

I''ll keep you informed and if you can think of anything else, let me know.

Thanks.

*******************
PetSound Industries
*******************
Always trying to help.
Will always try to deliver.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi, I am writing a program for DirectX screen capture. Do you know how to do now ? if you have a good function , could you give me one?
My email: sheng_zhi_hui@yahoo.com
thank you.

This is my code ( exist some errors ):

===========================================================
LPDIRECTDRAW lpDD = NULL;
LPDIRECTDRAWSURFACE lpDDSPrime = NULL;
LPDIRECTDRAWSURFACE lpDDSBack = NULL;
LPDIRECTDRAWSURFACE lpDDSGdi = NULL;
LPDIRECTDRAWSURFACE lpSurf = NULL;

// Init directx
int DX_Init()
{
HRESULT hr;
hr = DirectDrawCreate(0, &lpDD, 0);
if (FAILED(hr))
return FALSE;
hr = lpDD->SetCooperativeLevel(NULL, DDSCL_NORMAL);
if (FAILED(hr))
return FALSE;

ZeroMemory(&DDSdesc, sizeof(DDSdesc));
DDSdesc.dwSize = sizeof(DDSdesc);
DDSdesc.dwFlags = DDSD_CAPS;
DDSdesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = lpDD->CreateSurface(&DDSdesc, &lpDDSPrime, 0);
if (FAILED(hr))
return FALSE;

hr = lpDD->GetGDISurface(&lpDDSGdi);
if (FAILED(hr))
return FALSE;

ZeroMemory(&DDSdesc, sizeof(DDSdesc));
DDSdesc.dwSize = sizeof(DDSdesc);
DDSdesc.dwFlags = DDSD_ALL;
hr = lpDDSPrime->GetSurfaceDesc(&DDSdesc);
if (FAILED(hr))
return FALSE;

ZeroMemory(&DDSdesc, sizeof(DDSdesc));
DDSdesc.dwSize = sizeof(DDSdesc);
DDSdesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT
|DDSD_WIDTH;
DDSdesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
DDSdesc.dwHeight = m_bmrect.bottom - m_bmrect.top;
DDSdesc.dwWidth = m_bmrect.right - m_bmrect.left;
hr = lpDD->CreateSurface(&DDSdesc, &lpDDSBack, 0);
if (FAILED(hr))
return FALSE;
return TRUE;
}


BOOL CaptureScreen(RECT &rect, BYTE *scrBuff, UINT
scrBuffSize)
{
HRESULT hr=0;
hr =
lpDDSBack->BltFast
(rect.left,rect.top,lpDDSPrime,&rect,DDBLTFAST_NOCOLORKEY
| DDBLTFAST_WAIT);
if (FAILED(hr))
{
return FALSE;
}

DDSURFACEDESC surfdesc;
ZeroMemory(&surfdesc, sizeof(surfdesc));
surfdesc.dwSize = sizeof(surfdesc);

hr = lpDDSBack->Lock(&rect, &surfdesc,
DDLOCK_READONLY | DDLOCK_WAIT |
DDLOCK_SURFACEMEMORYPTR /*|DDLOCK_NOSYSLOCK*/, NULL);
if (FAILED(hr))
return FALSE;

// copy the data into our buffer
BYTE * destbuffpos, * srcbuffpos;
m_scrinfo.format.bitsPerPixel = 24;
srcbuffpos = (BYTE *) surfdesc.lpSurface;
destbuffpos = scrBuff;
memcpy( destbuffpos,
srcbuffpos,m_bminfo.bmi.bmiHeader.biSizeImage);
// unlock the primary surface
lpDDSBack->Unlock(surfdesc.lpSurface);
return TRUE;
}


When I run ''lpDDSBack->BltFast'' in ''CaptureScreen'', It
maybe return FALSE; or I run ''lpDDSBack->Lock'' in
''CaptureScreen'' ,the buffer maybe is Black data .

Share this post


Link to post
Share on other sites