Matthew, I want you to take a very close look at the screenshot you've provided by using any graphics editor and filling the black area with white. You're going to notice that not only are the leftover colours not the same as your tile, you're also going to notice FOUR different colours being left over. Each bright pixel has another one beside them. The ones beside the green pixels are a dark blue and the ones beside the red ones are very slightly green.
Those colours are NOT coming from your bitmaps. So where are they coming from?
First, you really need to change your naming conventions. Naming a global object "tile", another global object "Tile" and a local object in CTile "tile" is extremely confusing.
Secondly, you've got a memory leak. You're calling:
tile = create_bitmap(64, 64);
...and then immediately afterwards in the CTile::GetTile() routine you're changing that freshly created bitmap to point to:
tile = create_bitmap(m_TileWidth, m_TileHeight);
So that's definitely something you need to fix, but it's NOT the cause of the pixels you're seeing.
Your problem has to do with how you're grabbing your tiles. Miran said you should be using blit() instead of masked_blit(). I agree, but not just for the back buffer, EVERYWHERE, except cScreen :: DrawToBuffer(), you want to leave that one as masked_blit(), or even draw_sprite() to simplify things.
Think about this: When you allocate some memory nothing's in it, except possibly remnants from other things previously in memory. That's where those coloured pixels are coming from. So why aren't they disappearing when you grab your tile with CTile::GetTile()? Because you're grabbing your tile with masked_blit()! Because the tile you're trying to grab is completely transparent, masked_blit() doesn't paste anything onto your bitmap, thus it STILL has memory remnants in it!
blit() ignores transparent pixels, blitting them exactly as they are.
masked_blit() pays attention to transparent pixels by NOT blitting them.
So, you have three changes you need to make:
1. Change all masked_blit() commands to blit() except for the one in cScreen :: DrawToBuffer().
2. REMOVE: tile = create_bitmap(64, 64);
3. Call vsync() BEFORE drawing to the screen, not after.
And you really should have a unique name for absolutely everything global to minimize confusion.
That should solve your problems.
--- Kris Asick (Gemini)