Red,green and blue dot?

I am finishing an old project I started with sdl 1.2 and then going to convert it to the newest sdl version! My problem is a red green and blue dot that appears on the bottom left corner of some bitmaps rendered like this:

**SDL_Surface Video::LoadImage( std::string filename )
{
SDL_Surface
loadedImage = NULL;

SDL_Surface* optimizedImage = NULL;

loadedImage = SDL_LoadBMP( filename.c_str() );

if( loadedImage != NULL )
{
    optimizedImage = SDL_DisplayFormat( loadedImage );

    SDL_FreeSurface( loadedImage );
}

return optimizedImage;

}

void Video::DrawBmp(int x, int y,SDL_Surface* source, SDL_Surface* destination,bool transparent)
{
SDL_Rect offset;

offset.x = x;
offset.y = y;

if(transparent)
SDL_SetColorKey(source, SDL_SRCCOLORKEY, SDL_MapRGB(source->format, 0, 0, 0));

SDL_BlitSurface( source, NULL, destination, &offset );

}

bool Video::Update()
{
if( SDL_Flip(this->screen) == -1 ) return false;

return true;

}**

screen shot:
image

The red,green and blue dots appeared after I rendered the character’s boots the size of the bmp is 34 x 27 and the transparency is 0,0,0!

Sorry the image didnt show up!You can see the dots by the bottom left hand side of her dress.
image

Is the image you’ve posted the original image or a screenshot from when the program runs?

My guess is that it’s something with the color key’ing you’re doing in the render function.

Is the image you’ve posted the original image or a screenshot from when the program runs?

My guess is that it’s something with the color key’ing you’re doing in the render function.

Thanks for the quick reply I will look into the color keying. That is a screen shot here is one of the bmps that is effected:
image

[quote:068a66ec20=“Naith”]Is the image you’ve posted the original image or a screenshot from when the program runs?

My guess is that it’s something with the color key’ing you’re doing in the render function.

Thanks for the quick reply I will look into the color keying. That is a screen shot here is one of the bmps that is effected:
image[/quote:068a66ec20]

After I adjusted my color key SDL_SRCCOLORKEY to SDL_TRUE it produces this which will show exactly where the dots are being placed on the bott bmps.

image

May I look at your code (and not just the one you posted in your first post)? I have an idea on what might cause the problem. I will also need the affected image. I can’t see the image you’ve posted.

May I look at your code (and not just the one you posted in your first post)? I have an idea on what might cause the problem. I will also need the affected image. I can’t see the image you’ve posted.
I cant really share the whole source code or I would I’m building this project for someone else and theres alot of vultures that would like to get a hold of it! I am remaking a client for an old mmorpg that were trying to keep alive. I noticed someone else is having similar problems rebuilding his version of the client using sdl 2.0. Can be seen here http://www.treos.org/viewtopic.php?f=17&t=135&start=60

Oh, okay. I understand.

What I think you should do is:

  1. Move the SDL_SetColorKey code from the render function into the function where you’re creating the character and such, since the color keying only has to been done once for each surface, and not every frame.
    Might eventually cause some problems if color keying is being made every frame during rendering. Shouldn’t be any problems but it might case some weird effect.

Example:

void Init()
{
	SDL_Surface* pSurface = LoadImage("MyImage.bmp");

	// If the surface was successfully created, set the color key to black
	if(pSurface)
		SDL_SetColorKey(pSurface, SDL_SRCCOLORKEY, SDL_MapRGB(pSurface->format, 0, 0, 0));
}
  1. Make sure that the background on the image you’re loading only contains black so there isn’t any pixels in another color (like the pixels that appears at the left when rendering). There will be problems with the color keying if that’s the case.

Oh, okay. I understand.

What I think you should do is:

  1. Move the SDL_SetColorKey code from the render function into the function where you’re creating the character and such, since the color keying only has to been done once for each surface, and not every frame.
    Might eventually cause some problems if color keying is being made every frame during rendering. Shouldn’t be any problems but it might case some weird effect.

Example:

void Init()
{
	SDL_Surface* pSurface = LoadImage("MyImage.bmp");

	// If the surface was successfully created, set the color key to black
	if(pSurface)
		SDL_SetColorKey(pSurface, SDL_SRCCOLORKEY, SDL_MapRGB(pSurface->format, 0, 0, 0));
}
  1. Make sure that the background on the image you’re loading only contains black so there isn’t any pixels in another color (like the pixels that appears at the left when rendering). There will be problems with the color keying if that’s the case.

I tried moving the color function to each instance and I got the same result. I checked the bmps and their background/transparency and the bmps were fine.I removed the color key function completely to see what would happen and the dots still appear by the boots.

Are the dots appearing only for some of the bmp’s or all of them?

Have you considered switching to SDL_Image and loading the images as png files instead? By doing that, you don’t have to have a black background on each of the images and you don’t have do to any color keying, since SDL_Image takes care of the alpha layer and doesn’t render it.

Are the dots appearing only for some of the bmp’s or all of them?

Have you considered switching to SDL_Image and loading the images as png files instead? By doing that, you don’t have to have a black background on each of the images and you don’t have do to any color keying, since SDL_Image takes care of the alpha layer and doesn’t render it.

Its only on some bitmaps for instance most of the the boot bmps which are 34 x 27. I havnt tried SDL_Image because I would have to convert thousands of bmps to png files.If I can find a strait forward method to convert my bmps to png I will give your idea a shot.

I had a few ideas over night.
1: I’m going to try and slow down the program in between loading those bmps.
2: Instead of drawing the boots to the original screen I am going to draw them on the character.

I still feel like it’s something wrong with some of the bmp images since the error only occur on some of the images. I doubt that there’s some bug in SDL_LoadBMP and / or SDL_BlitSurface that would occur only on some of the surfaces. The only time when I’ve had rendering problems using SDL_BlitSurface is when I’ve made something wrong with the background color and color keying and such.

Yeah, that might be a good idea. Also, if I were you, I would try to turn off all the other assets that’s being rendered (backgrounds, menu buttons and so on) to see if it’s maybe some background or something that causes the rendering error(s). Might be a long shot but it’s worth to check.

I still feel like it’s something wrong with some of the bmp images since the error only occur on some of the images. I doubt that there’s some bug in SDL_LoadBMP and / or SDL_BlitSurface that would occur only on some of the surfaces. The only time when I’ve had rendering problems using SDL_BlitSurface is when I’ve made something wrong with the background color and color keying and such.

Yeah, that might be a good idea. Also, if I were you, I would try to turn off all the other assets that’s being rendered (backgrounds, menu buttons and so on) to see if it’s maybe some background or something that causes the rendering error(s). Might be a long shot but it’s worth to check.

Heres a zip files of the boot bmp’s https://www.mediafire.com/?rm2ua7di11n76vu maybe try and render a few of um . I can’t find anything wrong with them!

A lot of images there. Can you check for one of the images that the error occurs on and I will try to render it on my computer?

A lot of images there. Can you check for one of the images that the error occurs on and I will try to render it on my computer?

It happens at random I have a program I made to convert individual bmps to sheets and full sheets to bmps.I converted all those bmps to sprite sheets multiple times and it happens at random.Each time I turned the bmps to sheets the dots appeared on different instances! Here is the last result produced from bmp_2_spritesheet https://www.mediafire.com/?4kiuf646mq5t68q

I’ve now located the error.

Here’s a screenshot from a program I wrote to render 962 images at the same time (didn’t have room in the window to render more). As you can see in the image, some of the rendered surfaces has the small dots in them. We can therefore be sure that there’s nothing wrong with your code. Link to image: http://tinypic.com/view.php?pic=2qnqpg2&s=8#.U-FNeGPDUe9

In my program I counted which surface was the first to have the dot’s on it when rendered and opened up that image in Photoshop. I also located some more images to check. Here’s an image showing the images zoomed in a lot: http://tinypic.com/view.php?pic=n4tcm0&s=8#.U-FOQ2PDUe9

There’s the reason why you’re having dot’s on some surfaces during rendering. As you can see the issue seems to be very random since Bitmap_18.bmp and Bitmap_353 doesn’t have the dots but Bitmap_354 has. The issue is on some images in a row but there’s also images here and there that have the dots.

I’ve now located the error.

Here’s a screenshot from a program I wrote to render 962 images at the same time (didn’t have room in the window to render more). As you can see in the image, some of the rendered surfaces has the small dots in them. We can therefore be sure that there’s nothing wrong with your code. Link to image: http://tinypic.com/view.php?pic=2qnqpg2&s=8#.U-FNeGPDUe9

In my program I counted which surface was the first to have the dot’s on it when rendered and opened up that image in Photoshop. I also located some more images to check. Here’s an image showing the images zoomed in a lot: http://tinypic.com/view.php?pic=n4tcm0&s=8#.U-FOQ2PDUe9

There’s the reason why you’re having dot’s on some surfaces during rendering. As you can see the issue seems to be very random since Bitmap_18.bmp and Bitmap_353 doesn’t have the dots but Bitmap_354 has. The issue is on some images in a row but there’s also images here and there that have the dots.

This seems to be a bug in SDL and should be addressed! Im not doing anything abnormal with my program, I am just rendering at times thousands of bmps at the same time.

My thoughts: what whould happen if I changed the bmp size to 34 x 28 instead of 34 x 27,its just theirs to many figures I have to test alone :slight_smile:

Like I said, the dot’s are on the images even before they are loaded. Check the second of my images. That image shows a screenshot from Photoshop where I’ve openede some of the images and the dot’s are there. So the issue is in the images.

Like I said, the dot’s are on the images even before they are loaded. Check the second of my images. That image shows a screenshot from Photoshop where I’ve openede some of the images and the dot’s are there. So the issue is in the images.
In your post you said bitmap 354 has the dots,but it doesnt here is the original copy of the the image image . none of the boot bms have those dots Ive looked over them multiple times! How would the original game have been able to use the 0,0,0 transparency with those dots they would have and trust me I,ve been working with the server emulator for almost four years I know every in and out of the game and there was no weird rgb dots in the bottem of some bms.

[quote:a4dd9b66c6=“Naith”]Like I said, the dot’s are on the images even before they are loaded. Check the second of my images. That image shows a screenshot from Photoshop where I’ve openede some of the images and the dot’s are there. So the issue is in the images.
In your post you said bitmap 354 has the dots,but it doesnt here is the original copy of the the image image . none of the boot bms have those dots Ive looked over them multiple times! How would the original game have been able to use the 0,0,0 transparency with those dots they would have and trust me I,ve been working with the server emulator for almost four years I know every in and out of the game and there was no weird rgb dots in the bottem of some bms.[/quote:a4dd9b66c6]

Holly craPP the dots that show up on that link I posted last are not on the original image??? I have it inlarged in photo shop 700% and the whole surface beside the boot gfx is 0,0,0 :cry: