File: test-raico.c

package info (click to toggle)
notify-osd 0.9.35%2B15.04.20150126-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 2,016 kB
  • ctags: 1,837
  • sloc: ansic: 17,819; python: 1,100; makefile: 457; cs: 335; sh: 103; xml: 48
file content (88 lines) | stat: -rw-r--r-- 2,569 bytes parent folder | download | duplicates (3)
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
////////////////////////////////////////////////////////////////////////////////
//3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
//      10        20        30        40        50        60        70        80
//
// notify-osd
//
// raico-test.c - exercises the raico-API for blurring cairo image-surfaces
//
// Copyright 2009 Canonical Ltd.
//
// Authors:
//    Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License version 3, as published
// by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranties of
// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
// PURPOSE.  See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////

#include <cairo.h>

#include "raico-blur.h"

#define WIDTH  500
#define HEIGHT 500

int
main (int    argc,
      char** argv)
{
	cairo_surface_t* surface = NULL;
	cairo_t*         cr      = NULL;
	raico_blur_t*    blur    = NULL;

	// create and setup image-surface and context
	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
					      WIDTH,
					      HEIGHT);
	if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
	{
		g_debug ("Could not create image-surface!");
		return 1;
	}

	cr = cairo_create (surface);
	if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
	{
		cairo_surface_destroy (surface);
		g_debug ("Could not create cairo-context!");
		return 2;
	}

	// create and setup blur
	blur = raico_blur_create (RAICO_BLUR_QUALITY_LOW);
	raico_blur_set_radius (blur, 5);

	// draw something
	cairo_scale (cr, WIDTH, HEIGHT);
	cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
	cairo_paint (cr);
	cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 1.0f);
	cairo_set_line_width (cr, 0.02f);
	cairo_arc (cr, 0.5f, 0.5f, 0.4f, 0.0f, 360.0f * G_PI / 180.0f);
	cairo_stroke (cr);

	// now blur it
	raico_blur_apply (blur, surface);

	// save surface to a PNG-file
	cairo_surface_write_to_png (surface, "./raico-result.png");
	g_print ("See file raico-result.png in current directory for output.\n");

	// clean up
	cairo_destroy (cr);
	cairo_surface_destroy (surface);
	raico_blur_destroy (blur);

	return 0;
}