Hardware->hardware blits with color key

I load a surface from a file, then I create a resized one using zoomSurface
(SDL_rotozoom). I name it tmpSurfResize.
Then I create a copy in the video memory:

rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;

     tmpSurfFinal = SDL_CreateRGBSurface(SDL_HWSURFACE, tmpSurfResize->w,
       tmpSurfResize->h, 32, rmask,gmask,bmask,0);

     SDL_BlitSurface(tmpSurfResize, NULL, tmpSurfFinal, NULL);

     SDL_SetColorKey(tmpSurfFinal, SDL_SRCCOLORKEY, 

SDL_MapRGB(tmpSurfFinal->format, 255,0,255));
SDL_SetAlpha (tmpSurfFinal, 0, 0);

     return tmpSurfFinal;

Then I blit it on the screen.

 SDL_Rect srcrect,dstrect;

 /* Create a black background */
 SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0));

 srcrect.x = srcrect.y = 0;
 srcrect.w = logo_sword->w;
 srcrect.h = logo_sword->h;

 dstrect.x = dstrect.y = 0;

 SDL_BlitSurface(tmpSurfFinal, &srcrect, screen, &dstrect);

The screen was created this way:

screen = SDL_SetVideoMode (1024, 768, 32, flags);
if (screen == NULL)
fprintf (stderr, “Couldn’t set video mode: %s\n”, SDL_GetError ());
exit (1);

The results vary depending on the screen flags:
all goes well. The image is blitted correctly and the purple key
colour is not shown.
I get a really bad effect: while the foreground image is OK, the
purple background is stripped and teared by black lines. It also takes
noticeably more to load.

Now if I switch tmpSurfFinal to SDL_SWSURFACE, while keeping the screen as
hardware, all goes well.

This is my configuration:
Windows 2000 SP3
DirectX 9.0
GeForce4 MX440 64MB using GeForce 43.45 Win2K-XP drivers
Asus A7S333 with the latest BIOS
Athlon 2000+
2x 256MB DDR 266 MHz RAM.

Is colorkeying considered a “alpha blit”?

This is the result of the SDL test program:

Is it possible to create hardware surfaces? yes
Is there a window manager available? yes
Are hardware to hardware blits accelerated? yes
Are hardware to hardware colorkey blits accelerated? yes
Are hardware to hardware alpha blits accelerated? no
Are software to hardware blits accelerated? yes
Are software to hardware colorkey blits accelerated? yes
Are software to hardware alpha blits accelerated? no
Are color fills accelerated? yes
Total amount of video memory: 62272 kb

Thanks in advance for your help.

[] Guido Imperiale

crusaderky at libero.it

“Nam et ipsa scientia potestas est” (Knowledge is power)
– Sir Francis Bacon (1561-1626)
Meditationes Sacrae, de Haeresibus

“I worry about my child and the Internet all the time, even though she’s
too young to have logged on yet. Here’s what I worry about. I worry that 10
or 15 years from now, she will come to me and say ‘Daddy, where were you
when they took freedom of the press away from the Internet?’”
–Mike Godwin, Electronic Frontier Foundation