SDL_CreateRGBSurface vs. SDL_DisplayFormat

Hi,

I need to create a surface with the same format from another, but
with different size.

I tryed the code bellow, but something go wrong. Any idea ??=================================================================

newSurface = SDL_CreateRGBSurface(
oldSurface->flags, newWidth, newHeight,
oldSurface->format->BitsPerPixel,
oldSurface->format->Rmask, oldSurface->format->Gmask,
oldSurface->format->Bmask, oldSurface->format->Amask
);

=================================================================

Regards,

Herbert

I had trouble with similar code. THen someone pointed out this neat
trick… Instead of using “oldSurface->format->Amask”, try:

amask = ~(oldSurface->format->Rmask |
oldSurface->format->Gmask |
oldSurface->format->Bmask);

(where “amask” is of type “Uint32”; and notice that is “= ~” (equals not),
not “~=”), and use that as the amask you sent to SDL_CreateRGBSurface()

Let us know if that helps!

-bill!On Wed, Jun 25, 2003 at 10:28:02AM -0300, Herbert G. Fischer wrote:

I tryed the code bellow, but something go wrong. Any idea ??

=================================================================

newSurface = SDL_CreateRGBSurface(
oldSurface->flags, newWidth, newHeight,
oldSurface->format->BitsPerPixel,
oldSurface->format->Rmask, oldSurface->format->Gmask,
oldSurface->format->Bmask, oldSurface->format->Amask
);

=================================================================


bill at newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/

Thanks!

I’ll try later. I’m away from my code now…

Bill Kendrick wrote:> On Wed, Jun 25, 2003 at 10:28:02AM -0300, Herbert G. Fischer wrote:

I tryed the code bellow, but something go wrong. Any idea ??

=================================================================

newSurface = SDL_CreateRGBSurface(
oldSurface->flags, newWidth, newHeight,
oldSurface->format->BitsPerPixel,
oldSurface->format->Rmask, oldSurface->format->Gmask,
oldSurface->format->Bmask, oldSurface->format->Amask
);

=================================================================

I had trouble with similar code. THen someone pointed out this neat
trick… Instead of using “oldSurface->format->Amask”, try:

amask = ~(oldSurface->format->Rmask |
oldSurface->format->Gmask |
oldSurface->format->Bmask);

(where “amask” is of type “Uint32”; and notice that is “= ~” (equals not),
not “~=”), and use that as the amask you sent to SDL_CreateRGBSurface()

Let us know if that helps!

-bill!

El mi?, 25 de 06 de 2003 a las 11:24, Bill Kendrick escribi?:

I had trouble with similar code. THen someone pointed out this neat
trick… Instead of using “oldSurface->format->Amask”, try:

amask = ~(oldSurface->format->Rmask |
oldSurface->format->Gmask |
oldSurface->format->Bmask);

(where “amask” is of type “Uint32”; and notice that is “= ~” (equals not),
not “~=”), and use that as the amask you sent to SDL_CreateRGBSurface()

Let us know if that helps!

-bill!

As I can see I’m having same problem, I create a surface with previos
format->[RGBA]mask, then I SetAlpha(sfc, SDL_SRCALPHA, 255) but when I
FillRects with MapRGBA(r,g,b,a) I only get opaque rectangles, I tried
with this “trick” but I get everything BLACK, changing
SetAlpha(…,…,128) make the whole thing semitransparent :frowning:

Any help?–
pirata <@pirata>
-------------- next part --------------
A non-text attachment was scrubbed…
Name: smiley-6.png
Type: image/png
Size: 796 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030625/07013dce/attachment.png

It did not worked correctly.

It just worked as I was not erasing
sprite from old position. (as in
Windows Solitaire when you win a game).

Any idea ?

Herbert G. Fischer wrote:> Thanks!

I’ll try later. I’m away from my code now…

Bill Kendrick wrote:

On Wed, Jun 25, 2003 at 10:28:02AM -0300, Herbert G. Fischer wrote:

I tryed the code bellow, but something go wrong. Any idea ??

=================================================================

newSurface = SDL_CreateRGBSurface(
oldSurface->flags, newWidth, newHeight,
oldSurface->format->BitsPerPixel,
oldSurface->format->Rmask, oldSurface->format->Gmask,
oldSurface->format->Bmask, oldSurface->format->Amask
);

=================================================================

I had trouble with similar code. THen someone pointed out this neat
trick… Instead of using “oldSurface->format->Amask”, try:

amask = ~(oldSurface->format->Rmask |
oldSurface->format->Gmask |
oldSurface->format->Bmask);

(where “amask” is of type “Uint32”; and notice that is “= ~” (equals
not),
not “~=”), and use that as the amask you sent to SDL_CreateRGBSurface()

Let us know if that helps!

-bill!


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

It seem nobody answered my question, so I INSIST :stuck_out_tongue:

El mi?, 25 de 06 de 2003 a las 11:24, Bill Kendrick escribi?:
I had trouble with similar code. THen someone pointed out this neat
trick… Instead of using “oldSurface->format->Amask”, try:

  amask = ~(oldSurface->format->Rmask |
            oldSurface->format->Gmask |
            oldSurface->format->Bmask);

(where "amask" is of type "Uint32"; and notice that is "= ~" (equals not),
not "~="), and use that as the amask you sent to SDL_CreateRGBSurface()


Let us know if that helps!

-bill!

As I can see I’m having same problem, I create a surface with previos
format->[RGBA]mask, then I SetAlpha(sfc, SDL_SRCALPHA, 255) but when I
FillRects with MapRGBA(r,g,b,a) I only get opaque rectangles, I tried
with this “trick” but I get everything BLACK, changing
SetAlpha(…,…,128) make the whole thing semitransparent :frowning:

Any help?–
pirata <@pirata>

If I understand correctly, then I think your ‘problem’ is with SDL_FillRect().
If you read the documentation for SDL_FillRect() you will find:

“If the color value contains an alpha value then the destination is simply
’filled’ with that alpha information, no blending takes place.”

Hope that helps,

cheers,
John.On Sunday 29 June 2003 3:19 am, pirata wrote:

As I can see I’m having same problem, I create a surface with previos
format->[RGBA]mask, then I SetAlpha(sfc, SDL_SRCALPHA, 255) but when I
FillRects with MapRGBA(r,g,b,a) I only get opaque rectangles, I tried
with this “trick” but I get everything BLACK, changing
SetAlpha(…,…,128) make the whole thing semitransparent :frowning:

Any help?

As I can see I’m having same problem, I create a surface with previos
format->[RGBA]mask, then I SetAlpha(sfc, SDL_SRCALPHA, 255) but when I
FillRects with MapRGBA(r,g,b,a) I only get opaque rectangles, I tried
with this “trick” but I get everything BLACK, changing
SetAlpha(…,…,128) make the whole thing semitransparent :frowning:

Any help?

If I understand correctly, then I think your 'problem' is with SDL_FillRect(). 
If you read the documentation for SDL_FillRect() you will find:

"If the color value contains an alpha value then the destination is simply 
'filled' with that alpha information, no blending takes place."

Hope that helps,

cheers,
John.

Oops!, you’re right!, I missed it out
Thanks a lot
PirataOn Sun, 2003-06-29 at 13:33, john popplewell wrote:
On Sunday 29 June 2003 3:19 am, pirata wrote: