[cairo-commit] cairomm/examples/png_file Makefile.am, NONE,
1.1 main.cc, NONE, 1.1
Murray Cumming
commit at pdx.freedesktop.org
Sat Jan 7 03:53:04 PST 2006
- Previous message: [cairo-commit] cairomm/examples Makefile.am, 1.1.1.1,
1.2 Makefile.am_fragment, 1.1.1.1, 1.2 README, 1.1.1.1, 1.2
- Next message: [cairo-commit] cairo-perl Cairo.pm, 1.6, 1.7 Cairo.xs, 1.7,
1.8 ChangeLog, 1.13, 1.14 MakeHelper.pm, 1.3, 1.4 Makefile.PL,
1.10, 1.11 cairo-perl.h, 1.6, 1.7 cairo-perl.typemap, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: murrayc
Update of /cvs/cairo/cairomm/examples/png_file
In directory gabe:/tmp/cvs-serv1730/examples/png_file
Added Files:
Makefile.am main.cc
Log Message:
2006-01-06 Jonathon Jongsma <jonathon.jongsma at gmail.com>
* cairomm/surface.cc:
* cairomm/surface.h: Added implementation of write_to_png() and
write_to_png_stream() when PNG support is available in the base cairo
library
* examples/png_file/*: Added an example of creating an image surface and
saving it to a png image file
* examples/Makefile.am: add new example directory to SUBDIRS list
* configure.in: added output declaration for examples/png_file/Makefile
* examples/makefile.am_fragment: fix leftover libxml boilerplate
--- NEW FILE: Makefile.am ---
include $(top_srcdir)/examples/Makefile.am_fragment
# build the executable but don't install it
noinst_PROGRAMS = example_png_file
example_png_file_SOURCES = main.cc
--- NEW FILE: main.cc ---
#include <string>
#include <iostream>
#include <cairomm/cairomm.h>
int main(int argc, char** argv)
{
Cairo::RefPtr<Cairo::Surface> surface =
Cairo::Surface::create(CAIRO_FORMAT_ARGB32, 600, 400);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->save(); // save the state of the context
cr->set_source_rgb(0.86, 0.85, 0.47);
cr->paint(); // fill image with the color
cr->restore(); // color is back to black now
cr->save();
// draw a border around the image
cr->set_line_width(20.0); // make the line wider
cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height());
cr->stroke();
cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
// draw a circle in the center of the image
cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0,
surface->get_height() / 4.0, 0.0, 2.0 * M_PI);
cr->stroke();
// draw a diagonal line
cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0);
cr->line_to(surface->get_width() * 3.0 / 4.0, surface->get_height() * 3.0 / 4.0);
cr->stroke();
cr->restore();
#ifdef CAIRO_HAS_PNG_FUNCTIONS
std::string filename = "example_png_file.png";
surface->write_to_png(filename);
std::cout << "Wrote png file \"" << filename << "\"" << std::endl;
#else
std::cout << "You must compile cairo with PNG support for this example to work."
<< std::endl;
#endif
}
- Previous message: [cairo-commit] cairomm/examples Makefile.am, 1.1.1.1,
1.2 Makefile.am_fragment, 1.1.1.1, 1.2 README, 1.1.1.1, 1.2
- Next message: [cairo-commit] cairo-perl Cairo.pm, 1.6, 1.7 Cairo.xs, 1.7,
1.8 ChangeLog, 1.13, 1.14 MakeHelper.pm, 1.3, 1.4 Makefile.PL,
1.10, 1.11 cairo-perl.h, 1.6, 1.7 cairo-perl.typemap, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list