Problem with alpha

Hello sdl,

screen is 16bpp+ hw/sw surface with doublebuf

i alloc small surface for sprite like this

             fsObrazKlatki[ulLicznikKlatek] =
                    SDL_CreateRGBSurface(SDL_SWSURFACE,
                    uiSzerokoscKlatki[ulLicznikKlatek],
                    uiWysokoscKlatki[ulLicznikKlatek],16,0,0,0,0);  // tutaj obraz

first, i copy bitmap from buffer

            for (a1=0; a1<uiWysokoscKlatki[ulLicznikKlatek]; a1++)
            {
                    for (a2=0,a3=0; a3<uiSzerokoscKlatki[ulLicznikKlatek]; a2+=4,a3++)
                    {
                            SDL_pixelRGBA(fsObrazKlatki[ulLicznikKlatek], (short)a3,(short)a1,
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+2],
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+1], 
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2],
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+3]);
                    }
            }

i am sure about last alpha value (it is correct).

when i flip to screen i have black pixels when bgra = 0,0,0,0…

fliping method looks like this

    SDL_Rect        frRectangle;

    frRectangle.x=(short)ulXScreen; frRectangle.y=(short)ulYScreen;
    
    frRectangle.w=uiSzerokoscKlatki[ulFrame];
    frRectangle.h=uiWysokoscKlatki[ulFrame];

    SDL_BlitSurface((SDL_Surface*)fsObrazKlatki[ulFrame],NULL,fsDestination,&frRectangle);

and finally screen init looks like this…

    screen = SDL_SetVideoMode(800, 600, 16,
                    (SDL_SWSURFACE|SDL_ASYNCBLIT|SDL_DOUBLEBUF));

and i have no fuckin’ idea why diz doesn’t work. when using loop
with table and direct pixelRGBA instead of SDL_BlitSurface -
everything goes right way…

i was looking up for some answers in sdl sources but i didn’t find
any blit with alpha surface (ver 1.2.3)…

please help me ;)–
Best regards,
firefox mailto:@palpetine

Okresl Swoje potrzeby - my znajdziemy oferte za Ciebie!
[ http://oferty.onet.pl ]

First off, I really don’t think it’s legal to have all zeros in your
bitmask on the newly created surface. Perhaps that loads out the
surface with the defaults, but it’s not described as a behaviour in the
manual.

Anyway, aside from that, assuming that new surface IS valid. I’ve found
that blitting from a surface with an alpha channel into a newly created
surface with an alpha channel doesn’t transfer the alpha values from one
to the other. In other words… the alpha channel of your destination
surface is still fully transparent everywhere, even if colour data has
been moved, hence, against a black background, the surface appears to be
black.

I’m not sure any of this is helpful. But I hit a similar wall just a
couple of days ago.On Tue, 2002-03-05 at 07:15, firefox wrote:

Hello sdl,

screen is 16bpp+ hw/sw surface with doublebuf

i alloc small surface for sprite like this

             fsObrazKlatki[ulLicznikKlatek] =
                    SDL_CreateRGBSurface(SDL_SWSURFACE,
                    uiSzerokoscKlatki[ulLicznikKlatek],
                    uiWysokoscKlatki[ulLicznikKlatek],16,0,0,0,0);  // tutaj obraz

first, i copy bitmap from buffer

            for (a1=0; a1<uiWysokoscKlatki[ulLicznikKlatek]; a1++)
            {
                    for (a2=0,a3=0; a3<uiSzerokoscKlatki[ulLicznikKlatek]; a2+=4,a3++)
                    {
                            SDL_pixelRGBA(fsObrazKlatki[ulLicznikKlatek], (short)a3,(short)a1,
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+2],
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+1], 
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2],
                                    ucTempBuffer[ulOffset+(a1*(4*uiSzerokoscKlatki[ulLicznikKlatek]))+a2+3]);
                    }
            }

i am sure about last alpha value (it is correct).

when i flip to screen i have black pixels when bgra = 0,0,0,0…

fliping method looks like this

    SDL_Rect        frRectangle;

    frRectangle.x=(short)ulXScreen; frRectangle.y=(short)ulYScreen;
    
    frRectangle.w=uiSzerokoscKlatki[ulFrame];
    frRectangle.h=uiWysokoscKlatki[ulFrame];

    SDL_BlitSurface((SDL_Surface*)fsObrazKlatki[ulFrame],NULL,fsDestination,&frRectangle);

and finally screen init looks like this…

    screen = SDL_SetVideoMode(800, 600, 16,
                    (SDL_SWSURFACE|SDL_ASYNCBLIT|SDL_DOUBLEBUF));

and i have no fuckin’ idea why diz doesn’t work. when using loop
with table and direct pixelRGBA instead of SDL_BlitSurface -
everything goes right way…

i was looking up for some answers in sdl sources but i didn’t find
any blit with alpha surface (ver 1.2.3)…

please help me :wink:


Best regards,
firefox mailto:palpetine at poczta.onet.pl

Okresl Swoje potrzeby - my znajdziemy oferte za Ciebie!
[ http://oferty.onet.pl ]


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

End of Rant.

Jimmy
JimmysWorld.org
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: This is a digitally signed message part
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020305/10782f57/attachment.pgp

Hello Jimmy,

Tuesday, March 05, 2002, 6:16:51 PM, you wrote:

J> First off, I really don’t think it’s legal to have all zeros in your
J> bitmask on the newly created surface. Perhaps that loads out the
J> surface with the defaults, but it’s not described as a behaviour in the
J> manual.

hmm… indeed.

J> Anyway, aside from that, assuming that new surface IS valid. I’ve found
J> that blitting from a surface with an alpha channel into a newly created

yes, i realized diz myself. that’s why i am seeking another solution
to resolve this problem.

J> surface with an alpha channel doesn’t transfer the alpha values from one
J> to the other. In other words… the alpha channel of your destination

yeah, so why should i use surfaces if i can write my own blit func
with alpha support directly from pointer to table ?

J> surface is still fully transparent everywhere, even if colour data has
J> been moved, hence, against a black background, the surface appears to be
J> black.

yeah.

J> I’m not sure any of this is helpful. But I hit a similar wall just a
J> couple of days ago.

ok, thnx anyway.–
Best regards,
firefox mailto:@palpetine

Okresl Swoje potrzeby - my znajdziemy oferte za Ciebie!
[ http://oferty.onet.pl ]