~ubuntu-branches/ubuntu/precise/graphviz/precise-updates

« back to all changes in this revision

Viewing changes to plugin/pango/gvloadimage_pango.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-02-08 02:06:56 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080208020656-a3cbewe5ly6dpj0s
Tags: 2.16-3ubuntu1
* Merge with Debian; remaining changes:
  - Drop libttf-dev (libttf-dev is in universe) (LP: #174749).
  - Replace gs-common with ghostscript.
  - Build-depend on python-dev instead of python2.4-dev.
  - Build-depend on liblua50-dev instead of liblua5.1-0-dev.
  - Mention the correct python version for the python bindings in the
    package description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gvloadimage_pango.c,v 1.6 2006/07/27 00:40:43 ellson Exp $ $Revision: 1.6 $ */
 
1
/* $Id: gvloadimage_pango.c,v 1.10 2007/09/07 20:28:24 ellson Exp $ $Revision: 1.10 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
80
80
    return surface;
81
81
}
82
82
 
83
 
static void pango_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, bool filled)
 
83
static void pango_loadimage_cairo(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
84
84
{
85
 
    cairo_t *cr = (cairo_t *) job->surface; /* target context */
86
 
    cairo_surface_t *surface = NULL; /* source surface */
 
85
    cairo_t *cr = (cairo_t *) job->context; /* target context */
 
86
    cairo_surface_t *surface;    /* source surface */
87
87
 
88
88
    surface = cairo_loadimage(job, us);
89
89
    if (surface) {
97
97
    }
98
98
}
99
99
 
100
 
static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, bool filled)
 
100
static void pango_loadimage_ps(GVJ_t * job, usershape_t *us, boxf b, boolean filled)
101
101
{
102
 
    cairo_surface_t *surface = NULL; /* source surface */
 
102
    cairo_surface_t *surface;   /* source surface */
103
103
    FILE *out = job->output_file;
104
104
    int X, Y, x, y, stride;
105
105
    unsigned char *data, *ix, alpha, red, green, blue;
111
111
        stride = cairo_image_surface_get_stride(surface);
112
112
        data = cairo_image_surface_get_data(surface);
113
113
 
114
 
        fprintf(out, "gsave\n");
115
 
 
116
 
        /* this sets the position of the image */
117
 
        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
118
 
 
119
 
        /* this sets the rendered size to fit the box */
120
 
        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
121
 
 
122
 
        /* xsize ysize bits-per-sample [matrix] */
123
 
        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
124
 
 
125
 
        fprintf(out, "{<\n");
126
 
 
 
114
        fprintf(out, "save\n");
 
115
 
 
116
        /* define image data as string array (one per raster line) */
 
117
        /* see parallel code in gd_loadimage_ps().  FIXME: refactor... */
 
118
        fprintf(out, "/myctr 0 def\n");
 
119
        fprintf(out, "/myarray [\n");
127
120
        for (y = 0; y < Y; y++) {
 
121
            fprintf(out, "<");
128
122
            ix = data + y * stride;
129
123
            for (x = 0; x < X; x++) {
130
124
                /* FIXME - this code may have endian problems */
134
128
                alpha = *ix++;
135
129
                fprintf(out, "%02x%02x%02x", red, green, blue);
136
130
            }
137
 
            fprintf(out, "\n");
 
131
            fprintf(out, ">\n");
138
132
        }
139
 
 
140
 
        fprintf(out, ">}\n");
141
 
        fprintf(out, "false 3 colorimage\n");
142
 
 
143
 
        fprintf(out, "grestore\n");
 
133
        fprintf(out, "] def\n");
 
134
        fprintf(out,"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
 
135
 
 
136
        /* this sets the position of the image */
 
137
        fprintf(out, "%g %g translate %% lower-left coordinate\n", b.LL.x, b.LL.y);
 
138
 
 
139
        /* this sets the rendered size to fit the box */
 
140
        fprintf(out,"%g %g scale\n", b.UR.x - b.LL.x, b.UR.y - b.LL.y);
 
141
 
 
142
        /* xsize ysize bits-per-sample [matrix] */
 
143
        fprintf(out, "%d %d 8 [%d 0 0 %d 0 %d]\n", X, Y, X, -Y, Y);
 
144
 
 
145
        fprintf(out, "{myproc} false 3 colorimage\n");
 
146
 
 
147
        fprintf(out, "restore\n");
144
148
    }
145
149
}
146
150
 
155
159
 
156
160
gvplugin_installed_t gvloadimage_pango_types[] = {
157
161
#ifdef HAVE_PANGOCAIRO
158
 
    {FORMAT_PNG_CAIRO, "png2cairo", 1, &engine_cairo, NULL},
159
 
    {FORMAT_PNG_PS, "png2ps", 2, &engine_ps, NULL},
 
162
    {FORMAT_PNG_CAIRO, "png:cairo", 1, &engine_cairo, NULL},
 
163
    {FORMAT_PNG_PS, "png:ps", 2, &engine_ps, NULL},
160
164
#endif
161
165
    {0, NULL, 0, NULL, NULL}
162
166
};