Пример #1
0
/*
 * Open an output GIF file.
 */
    int
GIFmoOpen(WS_STATE_PTR ws)
{
  /* Output file not opened or written to until flushed */

    Gint status = 1;
    initLogFlag();
    assert(ws != NULL);
    assert(ws->wscolour <= gdMaxColors);
    if ((ws->mf.cgmo = (mf_cgmo*)umalloc(sizeof(mf_cgmo))) != NULL) {
	mf_cgmo	*cgmo	= ws->mf.cgmo;
	cgmo->ws = ws;

	if (find_meta(cgmo) != 0){
	  msgWarn("GIFmoOpen:metafile already open\n");
	} else {
	  create_meta(cgmo, DefaultSize, DefaultSize);
	  
	  cgmo->ws = ws;
	  cgmo->type = MF_GIF;
	  unlink(ws->conn);
	  status = OK;
	}
    }
    return status;
}
Пример #2
0
/*
 * Open an output PDF file.
 */
int
PDFmoOpen(WS_STATE_PTR ws)
{
    Gint status = 1;
    struct color_table *ptab;
    double tmp;
    cairo_surface_t *surface;
    initLogFlag();
    assert(ws != NULL);
    if ((ws->mf.cgmo = (mf_cgmo*)umalloc(sizeof(mf_cgmo))) != NULL) {
        mf_cgmo	*cgmo	= ws->mf.cgmo;

        if ((cgmo->fp = fopen(ws->conn, "w")) == NULL) {
            (void)CAIROmoClose(&ws->mf);
        } else {
            /* C. Doutriaux addition link to cairo lib */
#ifdef GENCAIRO
            printf("#include <cairo.h>\n#include <cairo-ps.h>\n#include <stdio.h>\n");
            printf(" cairo_status_t\nstream_cairo_write (void		*closure,\n	    const unsigned char	*data,\n	    unsigned int	 length)\n{\n  FILE	*fp = closure;\n  int i;\n  for(i=0;i<length;i++){\n    fputc( data[i],fp);\n  }\n  return CAIRO_STATUS_SUCCESS;\n};\n");
            printf("int main(){\ncairo_surface_t *surface;\ncairo_t *cr;\ncairo_pattern_t *pattern=NULL;\ncairo_surface_t *image=NULL;\ncairo_t *cr2=NULL;\n");
            printf("double dashes[4];\nint ndashes;\ncairo_matrix_t matrix;\nchar achar[2];\n");
            printf("FILE *fp;\n");
            printf("fp = fopen(\"test.pdf\",\"w\");\n");
            printf("surface = cairo_pdf_surface_create_for_stream(stream_cairo_write,fp,%i, %i);\n",XW,YW);
            printf("cr = cairo_create (surface);\n");
#endif
            surface = cairo_pdf_surface_create_for_stream(stream_cairo_write,
                      ws->mf.any->fp,
                      XW,YW);

#ifdef CAIRODRAW
            ws->cr = cairo_create (surface);
#endif
            cgmo->ws			= ws;
            cgmo->type			= MF_CAIRO;
            status	= OK;
        }
    }

    return status;
}