[SDL] Converting a surface to another color
Josh Matthews
mrlachatte at gmail.com
Sun Dec 31 21:26:51 PST 2006
Your best bet would probably be creating a default image in the GIMP with an
alpha mask, then load that with SDL_Image and overwrite the pixel data.
Alternatively, you could avoid the alpha mask and just use a color key by
creating an image with an inverted circle filled with pink. In SDL, make a
surface, fill it with your gradient, then copy the pink pixels into your
surface from your image, set the surface's color key and voila!
On 12/31/06, Viktor Dick <dickviktor at gmx.net> wrote:
>
> Thanks. If I understand rightly, the gradient function would put the
> lines with lineColor or something like that. Is there someone that could
> give me some code how to apply an alpa mask? I'm not familiar with
> transparency under SDL and I did not found any tutorial explaining this
> well enough.
> Thanks.
>
> Josh Matthews schrieb:
> > What if you had a gradient function that created rectangles, then used a
> > circular alpha mask?
> >
> > On 12/31/06, *Viktor Dick* < dickviktor at gmx.net
> > <mailto:dickviktor at gmx.net>> wrote:
> >
> > Hello,
> > I'm trying to write a simple 2D-program with SDL (I do not want to
> > use OpenGL).
> > It is almost ready, but at the moment I paint the marbles of the
> > players with
> > filledCircleColor. I have painted a circle with gimp with a gradient
> > from red
> > (bottom) to white (top) so it looks better. I can load the image to
> > the program,
> > but I need more colors and I do not want create an extra file for
> > each color. I
> > need also blue, green etc. marbles. Does anyone know how to change
> > the color in
> > a loaded surface? In the far future, it should also be possible to
> > let the users
> > switch their colors, so it would not be possible to give a picture
> > of each
> > possible color with the package.
> > Thanks
> > Viktor
> >
> >
> > _______________________________________________
> > SDL mailing list
> > SDL at libsdl.org <mailto:SDL at libsdl.org>
> > http://www.libsdl.org/mailman/listinfo/sdl
> >
> >
> >
> >
> > --
> > Cheers,
> > Josh
> >
> > PGP: http://revvy.box43.net/Josh_Matthews.asc
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
>
--
Cheers,
Josh
PGP: http://revvy.box43.net/Josh_Matthews.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070101/135466ec/attachment.htm
More information about the SDL
mailing list