36 gdImageDestroy(us->
data);
58 us->
data = gdImageCreateFromPng(us->
f);
63 us->
data = gdImageCreateFromGif(us->
f);
68 us->
data = gdImageCreateFromJpeg(us->
f);
84 gdImagePtr im2 = gdImageCreate(im->sy, im->sx);
86 gdImageCopyRotated(im2, im, im2->sx / 2., im2->sy / 2.,
87 0, 0, im->sx, im->sy, rotation);
96 gdImagePtr im2, im = job->
context;
108#ifdef HAVE_PANGOCAIRO
114 int x, y, width, height;
115 cairo_surface_t *surface;
121 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
125 unsigned char *
data =
gv_calloc((
size_t)stride, (
size_t)height);
126 surface = cairo_image_surface_create_for_data (
data, CAIRO_FORMAT_ARGB32,
127 width, height, stride);
128 unsigned char *
const orig_data =
data;
131 if (im->saveAlphaFlag) {
132 for (y = 0; y < height; y++) {
133 for (x = 0; x < width; x++) {
134 const int px = gdImageTrueColorPixel(im, x, y);
135 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
136 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
137 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
139 *
data++ = (
unsigned char)((0x7F - gdTrueColorGetAlpha(px)) << 1);
144 for (y = 0; y < height; y++) {
145 for (x = 0; x < width; x++) {
146 const int px = gdImageTrueColorPixel(im, x, y);
147 *
data++ = (
unsigned char)gdTrueColorGetBlue(px);
148 *
data++ = (
unsigned char)gdTrueColorGetGreen(px);
149 *
data++ = (
unsigned char)gdTrueColorGetRed(px);
156 for (y = 0; y < height; y++) {
157 for (x = 0; x < width; x++) {
158 const int px = gdImagePalettePixel(im, x, y);
159 *
data++ = (
unsigned char)im->blue[px];
160 *
data++ = (
unsigned char)im->green[px];
161 *
data++ = (
unsigned char)im->red[px];
162 *
data++ = px == im->transparent ? 0x00 : 0xff;
168 cairo_translate(cr, b.
LL.
x, -b.
UR.
y);
169 cairo_scale(cr, (b.
UR.
x - b.
LL.
x) / us->
w, (b.
UR.
y - b.
LL.
y) / us->
h);
170 cairo_set_source_surface (cr, surface, 0, 0);
174 cairo_surface_destroy(surface);
184 gdImagePtr im =
NULL;
194 gvputs(job,
"/myctr 0 def\n");
195 gvputs(job,
"/myarray [\n");
197 for (y = 0; y <
Y; y++) {
199 for (x = 0; x <
X; x++) {
200 px = gdImageTrueColorPixel(im, x, y);
202 gdTrueColorGetRed(px),
203 gdTrueColorGetGreen(px),
204 gdTrueColorGetBlue(px));
210 for (y = 0; y <
Y; y++) {
212 for (x = 0; x <
X; x++) {
213 px = gdImagePalettePixel(im, x, y);
223 gvputs(job,
"/myproc { myarray myctr get /myctr myctr 1 add def } def\n");
228 b.
LL.
y + (b.
UR.
y - b.
LL.
y) * (1. - (job->
dpi.
y) / 96.) / 2.);
238 gvputs(job,
"{myproc} false 3 colorimage\n");
252#ifdef HAVE_PANGOCAIRO
308#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)