35 gdImageDestroy(us->
data);
57 us->
data = gdImageCreateFromPng(us->
f);
62 us->
data = gdImageCreateFromGif(us->
f);
67 us->
data = gdImageCreateFromJpeg(us->
f);
83 gdImagePtr im2 = gdImageCreate(im->sy, im->sx);
85 gdImageCopyRotated(im2, im, im2->sx / 2., im2->sy / 2.,
86 0, 0, im->sx, im->sy, rotation);
95 gdImagePtr im2, im = job->
context;
107#ifdef HAVE_PANGOCAIRO
113 int x, y, width, height;
114 cairo_surface_t *surface;
120 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
124 unsigned char *
data =
gv_calloc((
size_t)stride, (
size_t)height);
125 surface = cairo_image_surface_create_for_data (
data, CAIRO_FORMAT_ARGB32,
126 width, height, stride);
127 unsigned char *
const orig_data =
data;
130 if (im->saveAlphaFlag) {
131 for (y = 0; y < height; y++) {
132 for (x = 0; x < width; x++) {
133 const int px = gdImageTrueColorPixel(im, x, y);
134 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
135 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
136 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
138 *
data++ = (
unsigned char)((0x7F - gdTrueColorGetAlpha(px)) << 1);
143 for (y = 0; y < height; y++) {
144 for (x = 0; x < width; x++) {
145 const int px = gdImageTrueColorPixel(im, x, y);
146 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
147 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
148 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
155 for (y = 0; y < height; y++) {
156 for (x = 0; x < width; x++) {
157 const int px = gdImagePalettePixel(im, x, y);
158 *
data++ = (
unsigned char)im->blue[px];
159 *
data++ = (
unsigned char)im->green[px];
160 *
data++ = (
unsigned char)im->red[px];
161 *
data++ = px == im->transparent ? 0x00 : 0xff;
167 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
168 cairo_scale(cr, (b.
UR.
x - b.
LL.
x) / us->
w, (b.
UR.
y - b.
LL.
y) / us->
h);
169 cairo_set_source_surface (cr, surface, 0, 0);
173 cairo_surface_destroy(surface);
183 gdImagePtr im =
NULL;
193 gvputs(job,
"/myctr 0 def\n");
194 gvputs(job,
"/myarray [\n");
196 for (y = 0; y <
Y; y++) {
198 for (x = 0; x <
X; x++) {
199 px = gdImageTrueColorPixel(im, x, y);
201 gdTrueColorGetRed(px),
202 gdTrueColorGetGreen(px),
203 gdTrueColorGetBlue(px));
209 for (y = 0; y <
Y; y++) {
211 for (x = 0; x <
X; x++) {
212 px = gdImagePalettePixel(im, x, y);
222 gvputs(job,
"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
227 b.
LL.
y + (b.
UR.
y - b.
LL.
y) * (1. - (job->
dpi.
y) / 96.) / 2.);
237 gvputs(job,
"{myproc} false 3 colorimage\n");
251#ifdef HAVE_PANGOCAIRO
307#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 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_loadimage(GVJ_t *job, usershape_t *us)
static gdImagePtr gd_rotateimage(gdImagePtr im, int rotation)
static gvloadimage_engine_t engine_cairo
void(* datafree)(usershape_t *us)