summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/ghosd/image.c
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2008-11-09 02:33:06 (GMT)
committerJames Meyer <james.meyer@operamail.com>2008-11-09 02:33:06 (GMT)
commit1ba69cc033dfbd0a6c4c29c6d877c7e753f96e8e (patch)
treef336ee91ce16c6591fff50340562e07e15aa1a55 /abs/mv-core/ghosd/image.c
parent75b1bceb21faab32d8f519d6f7f7062a226f9047 (diff)
downloadlinhes_pkgbuild-1ba69cc033dfbd0a6c4c29c6d877c7e753f96e8e.zip
linhes_pkgbuild-1ba69cc033dfbd0a6c4c29c6d877c7e753f96e8e.tar.gz
linhes_pkgbuild-1ba69cc033dfbd0a6c4c29c6d877c7e753f96e8e.tar.bz2
MythVantage specific pkgs
Diffstat (limited to 'abs/mv-core/ghosd/image.c')
-rw-r--r--abs/mv-core/ghosd/image.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/abs/mv-core/ghosd/image.c b/abs/mv-core/ghosd/image.c
new file mode 100644
index 0000000..cd5dadd
--- /dev/null
+++ b/abs/mv-core/ghosd/image.c
@@ -0,0 +1,97 @@
+/* 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
+char displayText[200] = "default message";
+
+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, 90.0);
+
+// cairo_move_to (cr, 10.0, 135.0);
+// cairo_show_text (cr, "Hello");
+
+cairo_move_to (cr, 70.0, 165.0);
+cairo_text_path (cr, displayText);
+cairo_set_source_rgb (cr, 1.5, 1.5, 1);
+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 == 2 )
+ {
+ sprintf(displayText, argv[1]);
+
+ }
+
+
+ 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, 1300, 6500);
+
+ return 0;
+}
+
+/* vim: set ts=2 sw=2 et cino=(0 : */