1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

eeshow/: PNG and PDF now write to standard output if -o outfile is absent

This commit is contained in:
Werner Almesberger
2016-08-02 11:45:44 -03:00
parent a941a5f246
commit 3864743280
45 changed files with 26 additions and 5917 deletions

View File

@@ -321,6 +321,19 @@ static void end_common(struct cro_ctx *cc, int *w, int *h)
}
static cairo_status_t stream_to_stdout(void *closure,
const unsigned char *data, unsigned length)
{
ssize_t wrote;
wrote = write(1, data, length);
if (wrote == (ssize_t) length)
return CAIRO_STATUS_SUCCESS;
perror("stdout");
return CAIRO_STATUS_WRITE_ERROR;
}
static void cr_png_end(void *ctx)
{
struct cro_ctx *cc = ctx;
@@ -341,8 +354,7 @@ static void cr_png_end(void *ctx)
record_replay(&cc->record);
record_destroy(&cc->record);
if (cc->output_name)
cairo_surface_write_to_png(cc->s, cc->output_name);
cro_img_write(cc, cc->output_name);
}
@@ -369,7 +381,11 @@ static void cr_pdf_end(void *ctx)
end_common(cc, &w, &h);
cc->s = cairo_pdf_surface_create(cc->output_name, w, h);
if (cc->output_name)
cc->s = cairo_pdf_surface_create(cc->output_name, w, h);
else
cc->s = cairo_pdf_surface_create_for_stream(stream_to_stdout,
NULL, w, h);
cc->cr = cairo_create(cc->s);
cairo_select_font_face(cc->cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL,
@@ -428,7 +444,11 @@ void cro_img_write(void *ctx, const char *name)
{
struct cro_ctx *cc = ctx;
cairo_surface_write_to_png(cc->s, name);
if (name)
cairo_surface_write_to_png(cc->s, name);
else
cairo_surface_write_to_png_stream(cc->s, stream_to_stdout,
NULL);
}

View File

@@ -258,8 +258,7 @@ static void diff_end(void *ctx)
differences(diff, old_img, diff->new_img);
show_areas(diff, old_img);
if (diff->output_name)
cro_img_write(diff->cr_ctx, diff->output_name);
cro_img_write(diff->cr_ctx, diff->output_name);
}

View File

@@ -60,7 +60,7 @@ void usage(const char *name)
"Cairo PNG driver spec:\n"
" png [-o output.png] [-s scale]\n"
"\n"
" -o output.png generate PNG output and write to specified file\n"
" -o output.png write PNG to specified file (default; standard output)\n"
" -s scale scale by indicated factor (default: 1.0)\n"
"\n"
"Cairo PDF driver spec:\n"