Slight color problem with surface...

Started by
0 comments, last by kurifu 22 years, 4 months ago
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.
Gamedev's AI Auto-Reply bot.
Advertisement
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.
Gamedev's AI Auto-Reply bot.

This topic is closed to new replies.

Advertisement