Non-screen surface to non-screen surface SDL_BlitRegion results black

Hello,

This is my first time posting to the list. I got into SDL
programming about 3 days ago.

I’m trying to blit one surface onto another. None of them is the
display. I get the second surface blank. Any idea on why it does
this?

For the moment I wrote my own pixel-by-pixel copy function, but
somehow I can’t use the surface colorkey attribute in any way to
check if I should copy a pixel or not. Testing for equality doesn’t
work, and masking the alpha value of the pixel so it’s always 0 and
so I can compare only RGB still doesn’t do anything.

Both surfaces have a 32 bit color depth. Blitting to the screen and
then trying to get the result out of there isn’t one of my options.

Platforms tested on:

  • Linux (Debian Sarge, SDL 1.2.7-7 from repository, g++ 3.3.4)
  • Windows (XP, SP2, SDL 1.2.7 latest from site, VS.NET 2002)

In short:

SDL_BlitSurface(Src, NULL, Dest, &Position)

gives a blank surface in Dest, although Position is updated
accordingly. Both Src and Dest are of type SDL_SWSURFACE, 32 bit
color depth and have no other parameters associated with them.

I tryed looking into the SDL source code, but I didn’t have time to
find how and where the actual blitter is since they are used by
means of function pointers, so I can’t submit a patch either.

Thanks.

BTW, is there an achive to this mailing list?–
Best regards,
Uplink mailto:@Uplink

Do you know that the &Position is changed after blit? Cannot be this the
problem?On Sat, 2004-09-11 at 00:35, Uplink wrote:

SDL_BlitSurface(Src, NULL, Dest, &Position)

gives a blank surface in Dest, although Position is updated
accordingly. Both Src and Dest are of type SDL_SWSURFACE, 32 bit
color depth and have no other parameters associated with them.


Ivo Danihelka

Hello Ivo,

I found out what it was.

The surface I was blitting to was created with SDL_CreateRGBSurface.
It seems that the surface created this way has an alpha value of 0
for all pixels?

The surface I was blitting from had SDL_SRCALPHA flag set and was
created with IMG_Load() from SDL_image with a .png file as
parameter.

If I was loading bitmaps, it worked. Once I loaded .png files, it
stopped working. Doing a SDL_FillRect(surface, NULL,
SDL_MapRGB(surface->format, 0, 0, 0)) on the target surface after
creating it seems to do the trick.

Saturday, September 11, 2004, you wrote:

ID> On Sat, 2004-09-11 at 00:35, Uplink wrote:

SDL_BlitSurface(Src, NULL, Dest, &Position)

gives a blank surface in Dest, although Position is updated
accordingly. Both Src and Dest are of type SDL_SWSURFACE, 32 bit
color depth and have no other parameters associated with them.

ID> Do you know that the &Position is changed after blit? Cannot be this the
ID> problem?–
Best regards,
Uplink mailto:@Uplink