Jump to content
  • Advertisement
Sign in to follow this  
tadobie

comparing apples and oranges!?

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

From what I understand lpSurface is the memory address of the pixels in the surface. If this is the case how can I get access to the actual pixel colour value so I can compare it to an RGB color value as in the line: if(colour == COL_COLLISION)
	Surface->LockSurface(overlapRect, sd);

	LPDWORD pixels = (LPDWORD)(sd.lpSurface);
	
	DWORD colour;
	
        for(int i = 0; i < (overlapRect.right-overlapRect.left)*(overlapRect.bottom-overlapRect.top); i++)
        {
		colour = pixels;
		if(colour == COL_COLLISION)
		{
			Surface->UnlockSurface(overlapRect);
			return true;
		}
       }

Share this post


Link to post
Share on other sites
Advertisement
Actually, you need to know different things such as the color format the surface is stored it. Dependently on that, you have either to decode it or compare it to a value that represents the collision color in that given color format.

What you need to know is that the number of bytes representing a color depends on the bitdepth of the surface. A 16 bit surface (being it 565, 1555, X555, ...) stores one pixel in 2 bytes. A 24 bit surface in 3 bytes and a 32 bit surface in 4 bytes.

Dependently on the bitdepth you have to a) read in the pixels, b) iterate through the bitmap and c) compare the value.

Share this post


Link to post
Share on other sites
The bit depth is 16 bits,
the color I want to compare in collision is RGB(1, 1, 1)
How would i go about iterating through the array and comparing the pixel values with the collision color?

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!