[cairo] multiple sprites images in one PNG

Arjen Nienhuis a.g.nienhuis at gmail.com
Fri Mar 16 12:10:54 PDT 2012


You can use ..._clip() or ..._rectangle() with ..._fill()

Gr. Arjen
On Mar 16, 2012 6:13 AM, "Christopher Howard" <
christopher.howard at frigidcode.com> wrote:

> Hi. I've got this noobie question. I posted it at the gtk list, but
> didn't get a response, so I'm going straight to the source:
>
> I'm coding a simple space combat game with GTK+/cairo. For the sprites,
> I know I can do this:
>
> code:
> ----------
> ship_surf = cairo_image_surface_create_from_png("ship.png");
> // ...
> cairo_set_source_surface (cr, ship_surf, x, y);
> cairo_paint (cr);
> ----------
>
> But what if I want, for ease of maintainability (and less system I/O
> calls) to put a whole bunch of sprites in one PNG? Is it possible for me
> to either...
>
> * load one PNG image into a surface, and then draw to a CR using only a
> small part of that surface?
>
> or
>
> * load one PNG into a surface, and then split that surface into multiple
> smaller surfaces?
>
> It wasn't quite clear to me from the documentation how I should go about
> this.
>
> --
> frigidcode.com
> indicium.us
>
>
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120316/fb152b58/attachment.htm>


More information about the cairo mailing list