Do you want to know how?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
bitmap info
lpDDSSurfaceMap->GetDC(&hdc);
color = GetPixel(hdc,mapx,mapy);
lpDDSSurfaceMap->ReleaseDC(hdc);
is there an easier/faster way of doing it?
This way isn't more simple than going through a DC, but I believe it is faster (It avoids going through the Win API, and GetDC implicity calls Lock and ReleaseDC calls Unlock).
This is the code that could do it:
code:char GetPixel(IDirectDrawSurface7 *lpDDSurface, DWORD x, DWORD y) { DDSURFACEDESC2 ddsd; ddsd.dwSize = sizeof(DDSURFACEDESC2); if (FAILED(lpDDSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL)) ; // error obtaining surface memory char nColor = *((char *)((int)ddsd.lpSurface + x + ddsd.lPitch * y)); lpDDSurface->Unlock(); return nColor;}
------------------
Where's my Golden Fleece?
[This message has been edited by Aeetes (edited December 20, 1999).]
Is there an easy way of doing this with directx?
unsigned char nColor = *((unsigned char *)((int)ddsd.lpSurface + x + ddsd.lPitch * y));
BUT this only puts the value of that place in nColor. So...you still need to find out the RGB color (in the palette itself).
I don't know how you load your bitmap. But if you use GetDIBits (I know, I know...it's slow, but only needs to be done once). You allocate enough memory for both the BITMAPINFOHEADER (so.....the size of the BITMAPINFOHEADER AND 256 * sizeof(RGBQUAD)...
and after that call GetDIBits TWICE!!!!!!!!!!!! The second time to load the palette.
If you use this method, you will then only have to put the value of that specific pixel into the palette thingy....and you get the color........
easy huh?
------------------
Dance with me......
http://members.xoom.com/CJdeVos/index.htm