Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cairo.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define SIZEX 1000
- #define SIZEY 500
- void paint(cairo_surface_t *cs)
- {
- cairo_t *c;
- c=cairo_create(cs);
- cairo_rectangle(c, 0.0, 0.0, SIZEX, SIZEY);
- cairo_set_source_rgb(c, 0.0, 0.0, 0.5);
- cairo_fill(c);
- cairo_move_to(c, 100.0, 100.0);
- cairo_set_source_rgb(c, 1.0, 1.0, 0.0);
- cairo_select_font_face (c, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (c, 52.0);
- cairo_show_text(c, "Hello World!");
- cairo_move_to(c, 200.0, 200.0);
- cairo_set_source_rgb(c, 1.0, 1.0, 0.0);
- cairo_select_font_face (c, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (c, 52.0);
- cairo_show_text(c, "Hello World!");
- cairo_move_to(c, 300.0, 300.0);
- cairo_set_source_rgb(c, 1.0, 1.0, 0.0);
- cairo_select_font_face (c, "Arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (c, 52.0);
- cairo_show_text(c, "Hello World!");
- cairo_show_page(c);
- cairo_destroy(c);
- }
- void writepng(const char *fname)
- {
- cairo_surface_t *cs;
- cs=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, SIZEX, SIZEY);
- paint(cs);
- cairo_surface_write_to_png(cs, fname);
- cairo_surface_destroy(cs);
- }
- int main() {
- writepng("image.png");
- }
Advertisement
Add Comment
Please, Sign In to add comment