summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/ghosd/image.c
blob: cd5daddf2ff6234fde419b3fec6428cad6215f22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 : */