Archived

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

Slight color problem with surface...

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

Ok, now I know this is something I am over looking because I have done this correctly before.. I am trying to draw a mouse cursor on my screen. It draws, however the colors come out to be very weird... This is what I have
// THIS IS WHERE WE WILL LITERALLY LOAD THE IMAGE
	hbm = ( HBITMAP )LoadImage( NULL, szBitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE /*| LR_CREATEDIBSECTION*/ );
 
I tried toggeling the LR_CREATEDIBSECTION parameter, but that yeilded no change what-so-ever.
HRESULT clTCoTDirectDrawMain::InitMouseCursor( ){
// JUST GO ON AND GUESS WHAT THIS FUNCTION DOES. REMEMBER TO FLIP THE BUFFERS YOURSELF.	

	// LOAD THE SURFACE WITH THE MOUSE POINTER ON IT...
	lpDDSMousePointer = DDLoadBitmap( lpDD, MOUSECURSOR );

	// SET A UNIVERSAL COLOR KEY.. ATTACH THIS TO THE MOUSE POINTER
	ddUniversalCK.dwColorSpaceLowValue = RGB( 255, 255, 255 );
	ddUniversalCK.dwColorSpaceHighValue = RGB( 255, 255, 255 );	
	lpDDSMousePointer->SetColorKey( DDCKEY_SRCBLT, &ddUniversalCK );

	return S_OK;
}
 
This pretty much sets up the color key, which is pure white. For reference, the image is a 24bpp bitmap. When drawing the image I make a call to lpDDSBack->Blt( ... ) like this:
HRESULT clTCoTDirectDrawMain::DrawMouseCursor( ){
// THIS FUNCTION WILL QUERY THE LAST KNOWN X/Y POSITION OF THE MOUSE AND DRAW THE SURSOR TO
// THE SCREEN. THERE IS ONE CATCH THOUGH... YOU HAVE TO CHECK FOR A MOUSE EVENT BEFORE CALLING
// THIS FUNCTION. THIS IS LEFT TO THE CODERS'' RESPONSABILITY.
	RECT DestRect;
	int x = TCoTDInputControl->GetMouseX( );
	int y = TCoTDInputControl->GetMouseY( );
	
	SetRect( &DestRect, x, y, x + 16, y + 16 );

	lpDDSBack->Blt( &DestRect, lpDDSMousePointer, NULL, DDBLT_KEYSRC | DDBLT_WAIT, NULL );

	return S_OK;
}
 
When the cursor is draw, it pretty much turns black (the colour of the background); however when you move it over something that it white it remains the black block with a few purple lines in it as it was to begin with. It literally appears to ibvert the colours, and does not seem to be colour keying properly. Any suggestions? Gamedev''s AI Auto-Reply bot.

Share this post


Link to post
Share on other sites
Hah.. never mind... I figured out the problem

I just spent nearly 2 hours trying to figure this out and I just realized now that I was not loading the correct image.

lol.

Gamedev''s AI Auto-Reply bot.

Share this post


Link to post
Share on other sites