35 gdImageDestroy(us->
data);
55 us->
data = gdImageCreateFromPng(us->
f);
60 us->
data = gdImageCreateFromGif(us->
f);
65 us->
data = gdImageCreateFromJpeg(us->
f);
81 gdImagePtr im2 = gdImageCreate(im->sy, im->sx);
83 gdImageCopyRotated(im2, im, im2->sx / 2., im2->sy / 2.,
84 0, 0, im->sx, im->sy, rotation);
93 gdImagePtr im2, im = job->
context;
105#ifdef HAVE_PANGOCAIRO
111 int x, y, width, height;
112 cairo_surface_t *surface;
118 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
122 unsigned char *
data =
gv_calloc((
size_t)stride, (
size_t)height);
123 surface = cairo_image_surface_create_for_data (
data, CAIRO_FORMAT_ARGB32,
124 width, height, stride);
125 unsigned char *
const orig_data =
data;
128 if (im->saveAlphaFlag) {
129 for (y = 0; y < height; y++) {
130 for (x = 0; x < width; x++) {
131 const int px = gdImageTrueColorPixel(im, x, y);
132 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
133 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
134 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
136 *
data++ = (
unsigned char)((0x7F - gdTrueColorGetAlpha(px)) << 1);
141 for (y = 0; y < height; y++) {
142 for (x = 0; x < width; x++) {
143 const int px = gdImageTrueColorPixel(im, x, y);
144 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
145 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
146 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
153 for (y = 0; y < height; y++) {
154 for (x = 0; x < width; x++) {
155 const int px = gdImagePalettePixel(im, x, y);
156 *
data++ = (
unsigned char)im->blue[px];
157 *
data++ = (
unsigned char)im->green[px];
158 *
data++ = (
unsigned char)im->red[px];
159 *
data++ = px == im->transparent ? 0x00 : 0xff;
165 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
166 cairo_scale(cr, (b.
UR.
x - b.
LL.
x) / us->
w, (b.
UR.
y - b.
LL.
y) / us->
h);
167 cairo_set_source_surface (cr, surface, 0, 0);
171 cairo_surface_destroy(surface);
181 gdImagePtr im =
NULL;
191 gvputs(job,
"/myctr 0 def\n");
192 gvputs(job,
"/myarray [\n");
194 for (y = 0; y <
Y; y++) {
196 for (x = 0; x <
X; x++) {
197 px = gdImageTrueColorPixel(im, x, y);
199 gdTrueColorGetRed(px),
200 gdTrueColorGetGreen(px),
201 gdTrueColorGetBlue(px));
207 for (y = 0; y <
Y; y++) {
209 for (x = 0; x <
X; x++) {
210 px = gdImagePalettePixel(im, x, y);
220 gvputs(job,
"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
225 b.
LL.
y + (b.
UR.
y - b.
LL.
y) * (1. - (job->
dpi.
y) / 96.) / 2.);
235 gvputs(job,
"{myproc} false 3 colorimage\n");
249#ifdef HAVE_PANGOCAIRO
305#ifdef HAVE_PANGOCAIRO
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
#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,...)
static gvloadimage_engine_t engine_ps
static void gd_loadimage_ps(GVJ_t *job, usershape_t *us, boxf b, bool filled)
static gdImagePtr gd_loadimage(usershape_t *us)
static void gd_freeimage(usershape_t *us)
static gvloadimage_engine_t engine
gvplugin_installed_t gvloadimage_gd_types[]
static void gd_loadimage_gd(GVJ_t *job, usershape_t *us, boxf b, bool filled)
static gdImagePtr gd_rotateimage(gdImagePtr im, int rotation)
static gvloadimage_engine_t engine_cairo
void(* datafree)(usershape_t *us)