28reader (
void *closure,
unsigned char *
data,
unsigned int length)
31 if (length == fread(
data, 1, length, (FILE *)closure)
32 || feof((FILE *)closure))
33 return CAIRO_STATUS_SUCCESS;
34 return CAIRO_STATUS_READ_ERROR;
39 cairo_surface_destroy(us->
data);
44 cairo_surface_t *surface =
NULL;
65#ifdef CAIRO_HAS_PNG_FUNCTIONS
67 surface = cairo_image_surface_create_from_png_stream(
reader, us->
f);
68 cairo_surface_reference(surface);
86 cairo_surface_t *surface;
99 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
100 cairo_scale(cr, (b.
UR.
x - b.
LL.
x)/(us->
w), (b.
UR.
y - b.
LL.
y)/(us->
h));
101 cairo_set_source_surface (cr, surface, 0, 0);
109 cairo_surface_t *surface;
111 int X,
Y, x, y, stride;
118 format = cairo_image_surface_get_format(surface);
119 if ((
format != CAIRO_FORMAT_ARGB32) && (
format != CAIRO_FORMAT_RGB24))
122 X = cairo_image_surface_get_width(surface);
123 Y = cairo_image_surface_get_height(surface);
124 stride = cairo_image_surface_get_stride(surface);
125 const unsigned char *
data = cairo_image_surface_get_data(surface);
131 gvputs(job,
"/myctr 0 def\n");
132 gvputs(job,
"/myarray [\n");
133 for (y = 0; y <
Y; y++) {
135 const unsigned char *ix =
data + y * stride;
136 for (x = 0; x <
X; x++) {
138 memcpy(&rgba, ix,
sizeof(rgba));
140 const unsigned blue = rgba & 0xff;
141 const unsigned green = (rgba >> 8) & 0xff;
142 const unsigned red = (rgba >> 16) & 0xff;
143 const unsigned alpha = (rgba >> 24) & 0xff;
147 gvprintf(job,
"%02x%02x%02x", red, green, blue);
152 gvputs(job,
"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
156 (b.
LL.
x + (b.
UR.
x - b.
LL.
x) * (1. - (job->
dpi.
x) / 96.) / 2.),
157 (b.
LL.
y + (b.
UR.
y - b.
LL.
y) * (1. - (job->
dpi.
y) / 96.) / 2.));
161 ((b.
UR.
x - b.
LL.
x) * 72. / 96.),
162 ((b.
UR.
y - b.
LL.
y) * 72. / 96.));
167 gvputs(job,
"{myproc} false 3 colorimage\n");
#define X(prefix, name, str, type, subtype,...)
void gvusershape_file_release(usershape_t *us)
bool gvusershape_file_access(usershape_t *us)
int gvputs(GVJ_t *job, const char *s)
void gvprintf(GVJ_t *job, const char *format,...)
GVIO_API const char * format
static gvloadimage_engine_t engine_ps
static gvloadimage_engine_t engine_cairo
gvplugin_installed_t gvloadimage_pango_types[]
static void pango_loadimage_cairo(GVJ_t *job, usershape_t *us, boxf b, bool filled)
static void cairo_freeimage(usershape_t *us)
static void pango_loadimage_ps(GVJ_t *job, usershape_t *us, boxf b, bool filled)
static cairo_surface_t * cairo_loadimage(GVJ_t *job, usershape_t *us)
static cairo_status_t reader(void *closure, unsigned char *data, unsigned int length)
void(* datafree)(usershape_t *us)