diff options
author | James Meyer <james.meyer@operamail.com> | 2009-02-23 21:19:04 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2009-02-23 21:19:04 (GMT) |
commit | 577c09bc1ea57e3fc5fe459ad91aafa4412b2297 (patch) | |
tree | 5fdcf480f545a75514783b155e3b23dea397eaf6 /abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c | |
parent | 1552b1b0221ed6a7e26e486187be25031408b453 (diff) | |
download | linhes_pkgbuild-577c09bc1ea57e3fc5fe459ad91aafa4412b2297.zip linhes_pkgbuild-577c09bc1ea57e3fc5fe459ad91aafa4412b2297.tar.gz linhes_pkgbuild-577c09bc1ea57e3fc5fe459ad91aafa4412b2297.tar.bz2 |
adding in ghosd
Diffstat (limited to 'abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c')
-rw-r--r-- | abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c b/abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c new file mode 100644 index 0000000..ed061af --- /dev/null +++ b/abs/mv-core/ghosd/ghosd-0.0.1/examples/image.c @@ -0,0 +1,113 @@ +/* ghosd -- OSD with fake transparency, cairo, and pango. + * Copyright (C) 2006 Evan Martin <martine@danga.com> + */ + +#include <stdio.h> +#include <math.h> +#include <cairo/cairo.h> +#include <unistd.h> +#include <ghosd/ghosd.h> + +#include "example-shared.h" + +#define MARGIN 10 +#define RADIUS 20 +#define WIDTH 185 +#define HEIGHT 220 + +int posX = 10; +int posY = 10; +char displayText[200] = "default message"; +float red = 1.0; +float green = 1.0; +float blue = 1.0; +int ftSize = 30; +int fadIn = 500; +int fadOt = 3300; + +static void +render(Ghosd *ghosd, cairo_t *cr, void* data) { + cairo_surface_t* image = data; + const int width = cairo_image_surface_get_width(image); + const int height = cairo_image_surface_get_height(image); + + cairo_set_source_rgba(cr, 0, 0, 0, 0.5); + cairo_new_path(cr); + example_round_rect(cr, 0, 0, width+(2*MARGIN), height+(2*MARGIN), RADIUS); + cairo_fill(cr); + + cairo_save(cr); + cairo_set_source_surface(cr, image, MARGIN, MARGIN); + + + + + cairo_paint_with_alpha(cr, 0.9); + cairo_restore(cr); +cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); +cairo_set_font_size (cr, ftSize); + +// cairo_move_to (cr, 10.0, 135.0); +// cairo_show_text (cr, "Hello"); + +cairo_move_to (cr, posX, posY); +cairo_text_path (cr, displayText); +cairo_set_source_rgb (cr, red, green, blue); +cairo_fill_preserve (cr); +cairo_set_source_rgb (cr, 0, 0, 0); +cairo_set_line_width (cr, 2.56); +cairo_stroke (cr); +} + +int main(int argc, char* argv[]) { + //g_type_init(); + + char *filename = NULL; + GOptionEntry options[] = { + { "image", 'i', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, + (gpointer)&filename, "image to display", "PATH" }, + { NULL } + }; + GOptionGroup *group = g_option_group_new("image", "Image Options", "image help", + NULL, NULL); + g_option_group_add_entries(group, options); + example_options_parse(&argc, &argv, group, NULL); + + if (filename == NULL) { + printf("must specify image with -i flag.\n" + "try e.g. /usr/share/pixmaps/gnome-logo-large.png\n"); + return 1; + } + + if( argc == 10 ) + { + + posX = atoi(argv[1]); + posY = atoi(argv[2]); + red = atoi(argv[3]); + green = atoi(argv[4]); + blue = atoi(argv[5]); + ftSize = atoi(argv[6]); + fadIn = atoi(argv[7]); + fadOt = atoi(argv[8]); +sprintf(displayText, argv[9]); + } + + + Ghosd *ghosd; + cairo_surface_t* image = cairo_image_surface_create_from_png(filename); + const int width = cairo_image_surface_get_width(image); + const int height = cairo_image_surface_get_height(image); + + ghosd = ghosd_new(); + ghosd_set_transparent(ghosd, opts.transparent); + ghosd_set_position(ghosd, opts.x, opts.y, + width+(2*MARGIN), height+(2*MARGIN)); + ghosd_set_render(ghosd, render, image); + + ghosd_flash(ghosd, fadIn, fadOt); + return 0; +} + +/* vim: set ts=2 sw=2 et cino=(0 : */ |