switch (job->device.id) {
#ifdef HAVE_GD_PNG
case FORMAT_PNG:
- if (data) {
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- color = *data++;
- /* gd's max alpha is 127 */
- /* so right-shift 25 to lose lsb of alpha */
- alpha = (color >> 25) & 0x7f;
- im->tpixels[y][x] = (color & 0xffffff) | ((0x7f - alpha) << 24);
- }
- }
- }
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ color = *data++;
+ /* gd's max alpha is 127 */
+ /* so right-shift 25 to lose lsb of alpha */
+ alpha = (color >> 25) & 0x7f;
+ im->tpixels[y][x] = (color & 0xffffff) | ((0x7f - alpha) << 24);
+ }
+ }
break;
#endif
default:
gdImageColorTransparent(im, TRANSPARENT);
gdImageAlphaBlending(im, FALSE);
- if (data) {
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- color = *data++;
- /* gd's max alpha is 127 */
- /* so right-shift 25 to lose lsb of alpha */
- if ((alpha = (color >> 25) & 0x7f) >= 0x20)
- /* if not > 75% transparent */
- im->tpixels[y][x] = (color & 0xffffff) | ((0x7f - alpha) << 24);
- else
- im->tpixels[y][x] = TRANSPARENT;
- }
- }
- }
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ color = *data++;
+ /* gd's max alpha is 127 */
+ /* so right-shift 25 to lose lsb of alpha */
+ if ((alpha = (color >> 25) & 0x7f) >= 0x20)
+ /* if not > 75% transparent */
+ im->tpixels[y][x] = (color & 0xffffff) | ((0x7f - alpha) << 24);
+ else
+ im->tpixels[y][x] = TRANSPARENT;
+ }
+ }
break;
}
case FORMAT_CAIRO:
default:
surface = cairo_get_target(cr);
+ if (cairo_image_surface_get_width(surface) == 0 || cairo_image_surface_get_height(surface) == 0) {
+ /* apparently cairo never allocates a surface if nothing was ever written to it */
+ fprintf(stderr, "ERROR: cairo surface has zero area, this may indicate some problem during rendering shapes.\n");
+ }
job->imagedata = (char *)(cairo_image_surface_get_data(surface));
break;
/* formatting will be done by gvdevice_format() */
cairogen_set_penstyle(job, cr);
cairo_get_matrix(cr, &matrix);
- cairo_translate(cr, A[0].x, -A[0].y);
rx = A[1].x - A[0].x;
ry = A[1].y - A[0].y;
- cairo_scale(cr, 1, ry / rx);
- cairo_move_to(cr, rx, 0);
- cairo_arc(cr, 0, 0, rx, 0, 2 * M_PI);
- cairo_close_path(cr);
+
+#define RMIN 0.01
+if (rx < RMIN) rx = RMIN;
+if (ry < RMIN) ry = RMIN;
+
+ cairo_translate(cr, A[0].x, -A[0].y);
+ cairo_scale(cr, rx, ry);
+ cairo_arc(cr, 0., 0., 1., 0., 2 * M_PI);
cairo_set_matrix(cr, &matrix);