Surface merging problem

Hi all

I like to merge two surfaces.
Surface 1 is created via loading a PNG file.
and Surface 2 as simply loading BMP file.
The issue is i like Surface 2 be the background of
Surface 1 so that backgound is visible after mergin the two.

How do i go about it ?

Ani suggestions…–
Thanks and Regards
Sachin

I like to merge two surfaces.
Surface 1 is created via loading a PNG file.
and Surface 2 as simply loading BMP file.
The issue is i like Surface 2 be the background of
Surface 1 so that backgound is visible after mergin the two.

How do i go about it ?

Ani suggestions…

Blit surface 1 onto surface 2? Unless you mean you want to blend the
two together… If you don’t know how to do the blit, take a look at
the SDL docs and tutorials linked to from the SDL website.

Matt

Thanks Matt

Well when i create and empty surface S and blit surface F to it
and then try to blit S to other it looses its per pixel alpha values.
and hence i get black background.

can you tell me how to preserve the per pixel alpha values of the
blitting surface when blitted to some target.

thanksOn Tuesday 19 July 2005 14:12, Matthew Hurne wrote:

I like to merge two surfaces.
Surface 1 is created via loading a PNG file.
and Surface 2 as simply loading BMP file.
The issue is i like Surface 2 be the background of
Surface 1 so that backgound is visible after mergin the two.

How do i go about it ?

Ani suggestions…

Blit surface 1 onto surface 2? Unless you mean you want to blend the
two together… If you don’t know how to do the blit, take a look at
the SDL docs and tutorials linked to from the SDL website.

Matt


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


Thanks and Regards
Sachin Sharma

Well when i create and empty surface S and blit surface F to it
and then try to blit S to other it looses its per pixel alpha values.
and hence i get black background.

can you tell me how to preserve the per pixel alpha values of the
blitting surface when blitted to some target.

thanks

Just a quick tip for you: when you reply, please put your reply text
underneath the message/section of the message you are replying to. It
makes it easier to follow the conversation. Writing a reply at the top
like you did is called “top posting” and its liable to anger some people
(not me though, at least not yet). :slight_smile:

Ok, well before I try to answer this, could you maybe send the relevant
code? You are blitting F to S, and the S to where? You’re likely going
to need to look at the SDL_SetAlpha and SDL_DisplayFormatAlpha
functions. SDL_SetAlpha is one I don’t fully understand but we will
probably manage to get it to do what you want; I just need more details
on what exactly you’re doing. Thanks…>On Tuesday 19 July 2005 14:12, Matthew Hurne wrote:

I like to merge two surfaces.
Surface 1 is created via loading a PNG file.
and Surface 2 as simply loading BMP file.
The issue is i like Surface 2 be the background of
Surface 1 so that backgound is visible after mergin the two.

How do i go about it ?

Ani suggestions…

Blit surface 1 onto surface 2? Unless you mean you want to blend the
two together… If you don’t know how to do the blit, take a look at
the SDL docs and tutorials linked to from the SDL website.

Matt


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

Well when i create and empty surface S and blit surface F to it
and then try to blit S to other it looses its per pixel alpha values.
and hence i get black background.

can you tell me how to preserve the per pixel alpha values of the
blitting surface when blitted to some target.

thanks

Just a quick tip for you: when you reply, please put your reply text
underneath the message/section of the message you are replying to. It
makes it easier to follow the conversation. Writing a reply at the top
like you did is called “top posting” and its liable to anger some people
(not me though, at least not yet). :slight_smile:

Ok, well before I try to answer this, could you maybe send the relevant
code? You are blitting F to S, and the S to where? You’re likely going
to need to look at the SDL_SetAlpha and SDL_DisplayFormatAlpha
functions. SDL_SetAlpha is one I don’t fully understand but we will
probably manage to get it to do what you want; I just need more details
on what exactly you’re doing. Thanks…

I like to merge two surfaces.
Surface 1 is created via loading a PNG file.
and Surface 2 as simply loading BMP file.
The issue is i like Surface 2 be the background of
Surface 1 so that backgound is visible after mergin the two.

How do i go about it ?

Ani suggestions…

Blit surface 1 onto surface 2? Unless you mean you want to blend the
two together… If you don’t know how to do the blit, take a look at
the SDL docs and tutorials linked to from the SDL website.

Matt


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


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

Thanks Matt

Well I explain you all.
I have a number of images which have alpha channel,
and each pixel has its alpha value.
I load them into individual surfaces, do some manipulation.
Now i create one surface S using SDL_CreateRGBSurface,
and blit my surfaces created above to this S surface, but here while
blitting, the alpha values of each pixel is not transfered to S.
What i need is just copy to surface S including all RGBA values.
Is there any option in SDL_BlitSurface to to just copy or just
a way around to do it.

Thanks
sachinOn Tuesday 19 July 2005 16:32, Matthew Hurne wrote:

On Tuesday 19 July 2005 14:12, Matthew Hurne wrote:

Thanks and Regards
Sachin Sharma

Thanks Matt

Well I explain you all.
I have a number of images which have alpha channel,
and each pixel has its alpha value.
I load them into individual surfaces, do some manipulation.
Now i create one surface S using SDL_CreateRGBSurface,
and blit my surfaces created above to this S surface, but here while
blitting, the alpha values of each pixel is not transfered to S.
What i need is just copy to surface S including all RGBA values.
Is there any option in SDL_BlitSurface to to just copy or just
a way around to do it.

Thanks
sachin

Maybe this is a dumb question, but what’s the type of the images you are
loading? BMP, PNG, JPG…etc.? And are you loading with SDL_LoadBMP
or are you using SDL_image?

Try calling SDL_SetAlpha(surface, 0, 0) on an image before you blit it.
Just for the heck of it. Lol. I’m not an SDL expert to be honest so
I’m doing the best I can but I can’t be sure exactly what you’re code is
doing and what you’re trying to do some I just throwing out some
suggestions. Also, what flags are you giving SDL_CreateRGBSurface? It
might be easier to create the S surface by calling SDL_DisplayFormat on
another surface of the same size you want the new surface to be (if you
have one). Or maybe it will help to call that on the surface you create
with SDL_CreateRGBSurface before trying to blit to it. I don’t know if
you’ve noticed but I’ve sent a few messages to the list myself trying to
understand how alpha blending works and as of yet I haven’t gotten any
real solutions so I’m somewhat in the dark as well.

Matt