Пример #1
0
void FIF(g2_string)(F_REAL *dev, F_REAL *x, F_REAL *y, F_CHAR *text,
		    F_CHAR_LENGTH length)
{
    char *str;
    str=g2_malloc((length+1)*sizeof(char));
    strncpy(str, text, length);
    str[length]='\0';
    g2_string(dtoi(*dev), *x, *y, str);
    g2_free(str);
}
Пример #2
0
F_REAL FIF(g2_open_ps)(F_CHAR *text, F_REAL *paper, F_REAL *orientation,
		       F_CHAR_LENGTH length)
{
    char *str;
    int rv;

    str=g2_malloc((length+1)*sizeof(char));
    strncpy(str, text, length);
    str[length]='\0';
    rv=g2_open_PS(str, dtoi(*paper), dtoi(*orientation));
    g2_free(str);
    
    return (F_REAL)rv;
}
Пример #3
0
/* thanks to Yuri Sbitnev for contributing the g2_image code for FORTRAN */
void FIF(g2_image)(F_REAL *dev, F_REAL *x, F_REAL *y, F_REAL *x_size, F_REAL *y_size,
		   F_REAL *pens)
{
    int i, j, xs, ys;
    int *mypens;
    xs=dtoi(*x_size);
    ys=dtoi(*y_size);
    mypens=(int *) g2_malloc(xs*ys*sizeof(int));
    for(j=0;j<ys;j++) 
      for(i=0;i<xs;i++) 
        mypens[j*xs+i]=dtoi(pens[j*xs+i]);         /* pens[dtoi(*y_size)][dtoi(*x_size)] */
    g2_image(dtoi(*dev), *x, *y, xs, ys, mypens);
    g2_free(mypens);
}
Пример #4
0
F_REAL FIF(g2_open_gd)(F_CHAR *text, F_REAL *width, F_REAL *height, F_REAL *gd_type,
			F_CHAR_LENGTH length)
{
    char *str;
    int rv;
    
    str=g2_malloc((length+1)*sizeof(char));
    strncpy(str, text, length);
    str[length]='\0';

    rv=g2_open_gd(str, *width, *height, *gd_type);
    
    g2_free(str);
    
    return (F_REAL)rv;
}
Пример #5
0
int g2_PS_ink(int pid, void *pdp,
              double red, double green, double blue)
{
    g2_PS_device *ps=&g2_PS_dev[pid];
    ps->N_ink++;
    if(ps->inks==NULL)
        ps->inks=(g2_PS_inks *)g2_malloc(ps->N_ink*
                                         sizeof(g2_PS_inks));
    else
        ps->inks=(g2_PS_inks *)g2_realloc((void *)ps->inks,
                                          ps->N_ink*
                                          sizeof(g2_PS_inks));

    ps->inks[ps->N_ink-1].r=red;
    ps->inks[ps->N_ink-1].g=green;
    ps->inks[ps->N_ink-1].b=blue;

    return ps->N_ink-1;
}
Пример #6
0
/*
 *
 * Attach generic PS device
 *
 */
G2L int g2_open_PS_generic(const char *file_name,
	       enum g2_PS_paper paper,
	       enum g2_PS_orientation orientation,
		   enum g2_PS_format format,
		   long width,
		   long height)
{
    g2_PS_device *psout=NULL;
    int pid=-1, i;
    int vid;
    FILE *fp;

    if((fp=fopen(file_name, "w"))==NULL) {
	fprintf(stderr, "g2_attach_PS: Error! Can not open file '%s'\n",
		file_name);
	return -1;
    }
    
    if(g2_PS_dev==NULL) {
	g2_PS_dev=g2_malloc(sizeof(g2_PS_device));
	N_PS=1;					  /* first PS device */
	psout=&g2_PS_dev[N_PS-1];
	pid=0;
    } else {
	for(i=0;i<N_PS;i++)			  /* find free place */
	    if(g2_PS_dev[i].fp==NULL) {
		psout=&g2_PS_dev[i];
		pid=i;
		break;
	    }
	if(i==N_PS) {				  /* free place not avail. */
	    N_PS++;
	    g2_PS_dev=g2_realloc(g2_PS_dev,
				 sizeof(g2_PS_device)*N_PS);
	    psout=&g2_PS_dev[N_PS-1];
	    pid=N_PS-1;
	}
    }

    vid = g2_register_physical_device(pid, NULL,
				      g2_DoubleCoor, g2_PS_funix,
				      1.0, 1.0,
				      0.0, 0.0);

    psout->fp=fp;			      /* init PostScript structures */
    psout->paper=paper;
    psout->orient=orientation;
    psout->format=format;
    psout->width=width;
    psout->height=height;
    psout->inks=NULL;
    psout->N_ink=0;
    psout->pen=0;
    psout->page_counter=0;
    psout->bbox = 0;
	
    g2_PS_write_file_header(psout);
    
    g2_PS_set_line_width(pid, NULL, 0.0);
    g2_PS_set_font_size(pid, NULL, 12.0);

					    /* g2 settings */
    g2_allocate_basic_colors(vid);
    g2_pen(vid, 1);
    
    return vid;
}