Hello!
Thanks for your answer!
One thing I notice is that ‘tmp’ has no colorkey, but not all of it gets
written to. Half of it’s left unwritten, hence pure black – this black is
going to ahnnialate…agnigle…wreck the other half of draw->work when you
copy tmp over it.
If you’re trying to mirror it down the middle, which is what I’m guessing this
does, you should only blit half of tmp back, not all of it:
{
SDL_Rect src={(draw->work->w/2)+1, 0, draw->work->w/2, draw->work->h };
SDL_BlitSurface (tmp,&src,draw->work,&src);
}
You can also speedup your code a bit by blitting column per column instead of
pixel per pixel:
for (xf = 0; xf < draw->work->w / 2; xf ++)
{
SDL_Rect a = {xf, 0, 1, draw->work->h};
SDL_Rect b = {draw->work->w - xf, 0, draw->work->h, 1};
SDL_BlitSurface (draw->work, &a, tmp, &b);
}
I changed the code as you suggested but draw->work still looks like tmp
wasn’t blitted “over” it… it looks like before… like nothing happened…
if (draw->work)
{
int xf = 0, yf = 0;
SDL_Surface *tmp = SDL_CreateRGBSurface (SDL_SWSURFACE,
draw->work->w,
draw->work->h,
32,
draw->work->format->Rmask,
draw->work->format->Gmask,
draw->work->format->Bmask,
draw->work->format->Amask);
SDL_SetColorKey (tmp, SDL_SRCCOLORKEY, 0);
for (xf = 0; xf < draw->work->w / 2; xf ++)
{
SDL_Rect a = {xf, 0, 1, draw->work->h};
SDL_Rect b = {draw->work->w - xf, 0, 1, draw->work->h};
SDL_BlitSurface (draw->work, &a, tmp, &b);
}
SDL_BlitSurface (tmp, NULL, draw->work, NULL);
SDL_FreeSurface (tmp);
}
i must admit that i didn’t know that SDL_SetColorKey() would be
necessary… but it didn’t change anything (neither to the worse or the
better…)… it’s just like the image was loaded and blitted to the
screen… :-/ …should i quote more code?
Dirk