コード例 #1
0
ファイル: tek.c プロジェクト: WenchaoLin/JAMg
void 
plD_state_tek(PLStream *pls, PLINT op)
{
    TekDev *dev = (TekDev *) pls->dev;

    switch (op) {

    case PLSTATE_WIDTH:
	break;

    case PLSTATE_COLOR0:
	if (pls->color) {
	    int icol0 = pls->icol0;
	    tek_graph(pls);
	    if (icol0 != PL_RGB_COLOR) {
		dev->curcolor = icol0;
		tek_color(pls, icol0);
	    }
	}
	break;

    case PLSTATE_COLOR1:
	if (pls->color) {
	    int icol1, ncol1;
	    tek_graph(pls);
	    if ((ncol1 = MIN(16 - pls->ncol0, pls->ncol1)) < 1)
		break;

	    icol1 = pls->ncol0 + (pls->icol1 * (ncol1-1)) / (pls->ncol1-1);
	    dev->curcolor = icol1;
	    tek_color(pls, icol1);
	}
	break;

    case PLSTATE_CMAP0:
    case PLSTATE_CMAP1:
	if ( pls->color & 0x01 )
	    setcmap(pls);    

	break;
    }
}
コード例 #2
0
ファイル: tek.c プロジェクト: WenchaoLin/JAMg
void
plD_bop_tek(PLStream *pls)
{
   TekDev *dev = (TekDev *) pls->dev;

   dev->xold = PL_UNDEFINED;
   dev->yold = PL_UNDEFINED;

   if (pls->termin) {
       switch (pls->dev_minor) {
       case mskermit:
	   fprintf(pls->OutFile, CLEAR_VIEW);	/* erase and home */
	   break;
       }
   } else {
       plGetFam(pls);
   }
   pls->page++;

/* Initialize palette */

   if ( pls->color & 0x01 )
       setcmap(pls);
}
コード例 #3
0
void
plD_state_png(PLStream *pls, PLINT op)
{
png_Dev *dev=(png_Dev *)pls->dev;
PLFLT tmp_colour_pos;
#if GD2_VERS >= 2
long temp_col;
#endif


    switch (op) {

#if GD2_VERS >= 2
    case PLSTATE_WIDTH:
        gdImageSetThickness(dev->im_out, pls->width);
	break;
#endif

    case PLSTATE_COLOR0:
#if GD2_VERS >= 2

	if ( (pls->icol0 == PL_RGB_COLOR)||     /*  Should never happen since PL_RGB_COLOR is depreciated, but here for backwards compatibility */
             (gdImageTrueColor(dev->im_out)) )  /*  We will do this if we are in "TrueColour" mode */
           {
	    if ( (dev->totcol < NCOLOURS)||         /* See if there are slots left, if so we will allocate a new colour */
                 (gdImageTrueColor(dev->im_out)) )  /* In TrueColour mode we allocate each colour as we come to it */
	       {
	        /* Next allocate a new colour to a temporary slot since what we do with it will varay depending on if its a pallter index or truecolour */
                temp_col=gdImageColorAllocate(dev->im_out,pls->curcolor.r,
                                             pls->curcolor.g, pls->curcolor.b);

                if (gdImageTrueColor(dev->im_out))
                    dev->colour = temp_col;     /* If it's truecolour, then we will directly set dev->colour to our "new" colour */
                else
                    {
                     dev->colour = dev->totcol;  /* or else, we will just set it to the last colour */
                     dev->totcol++;              /* Bump the total colours for next time round */
                    }
	       }

           }
         else  /* just a normal colour allocate, so don't worry about the above stuff, just grab the index */
           {
            dev->colour = pls->icol0;
           }

#else
	dev->colour = pls->icol0;
	if (dev->colour == PL_RGB_COLOR)
           {
	    if (dev->totcol < NCOLOURS)
	       {
                gdImageColorAllocate(dev->im_out,pls->curcolor.r, pls->curcolor.g,  pls->curcolor.b);
		dev->colour = dev->totcol;
	       }

           }
#endif
	break;

    case PLSTATE_COLOR1:

#if GD2_VERS >= 2
       if (!gdImageTrueColor(dev->im_out))
          {
#endif
           /*
            * Start by checking to see if we have to compensate for cases where
            * we don't have the full dynamic range of cmap1 at our disposal
            */
           if (dev->ncol1<pls->ncol1)
              {
               tmp_colour_pos=dev->ncol1*((PLFLT)pls->icol1/(pls->ncol1>0 ? pls->ncol1 : 1));
               dev->colour = pls->ncol0 + (int)tmp_colour_pos;
              }
           else
              dev->colour = pls->ncol0 + pls->icol1;
#if GD2_VERS >= 2
           }
        else    /* it is a truecolour image */
           {
             dev->colour = gdTrueColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b);
           }
#endif
	break;


    case PLSTATE_CMAP0:
    case PLSTATE_CMAP1:

#if GD2_VERS >= 2
       if ((dev->im_out != NULL) && !gdImageTrueColor(dev->im_out))
          {
#endif

    /*
     *  Code to redefine the entire palette
     */


	if (pls->color)
	    setcmap(pls);

#if GD2_VERS >= 2
}
#endif

	break;
    }
}
コード例 #4
0
void plD_bop_png(PLStream *pls)
{
    png_Dev *dev;

    plGetFam(pls);
/* force new file if pls->family set for all subsequent calls to plGetFam
 * n.b. putting this after plGetFam call is important since plinit calls
 * bop, and you don't want the familying sequence started until after
 * that first call to bop.*/

/* n.b. pls->dev can change because of an indirect call to plD_init_png
 * from plGetFam if familying is enabled.  Thus, wait to define dev until
 * now. */

    dev = (png_Dev *) pls->dev;

    pls->famadv = 1;

    pls->page++;

if (dev->black15) plD_black15_gd(pls);
if (dev->red15) plD_red15_gd(pls);

#if GD2_VERS >= 2
  if ( ( (((dev->truecolour>0) && (dev->palette>0)) ||     /* In an EXTREMELY convaluted */
         ((dev->truecolour==0) && (dev->palette==0))) &&   /* manner, all this is just   */
          ((pls->ncol1+pls->ncol0) <= 256) ) ||             /* asking the question, do we */
       (((dev->palette>0) && (dev->truecolour==0)))  )   /* want truecolour or not ?   */
        {
#endif

           dev->im_out = gdImageCreate(pls->xlength, pls->ylength);

           setcmap(pls);

#if GD2_VERS >= 2
         }
       else
         {
         dev->im_out = gdImageCreateTrueColor(pls->xlength, pls->ylength);

/*
 * In truecolour mode, the background colour GD makes is ALWAYS black, so to
 * "simulate" (stimulate?) a background colour other than black, we will just
 * draw a dirty big rectange covering the whole image and colour it in
 * whatever colour cmap0[0] happens to be.
 *
 * Question to C gurus: while it is slightly illogical and ugly, would:
 *   if ((pls->cmap0[0].r+pls->cmap0[0].g+pls->cmap0[0].b)!=0)
 * be more computationally efficient than:
 *   if ((pls->cmap0[0].r!=0)||(pls->cmap0[0].g!=0)||(pls->cmap0[0].b!=0))
 *  ???
 */

         if ( (pls->cmap0[0].r!=0)||(pls->cmap0[0].g!=0)||
              (pls->cmap0[0].b!=0) )
            {
             gdImageFilledRectangle(dev->im_out,0,0, pls->xlength-1, pls->ylength-1,
                                    gdTrueColor(pls->cmap0[0].r,pls->cmap0[0].g,
                                                pls->cmap0[0].b));
            }

         }


/* This ensures the line width is set correctly at the beginning of
 *    each page */

   plD_state_png(pls, PLSTATE_WIDTH);

#endif


}
コード例 #5
0
ファイル: tek.c プロジェクト: WenchaoLin/JAMg
static void
tek_init(PLStream *pls)
{
    TekDev *dev;
    int xmin = 0;
    int xmax = TEKX;
    int ymin = 0;
    int ymax = TEKY;

    PLFLT pxlx = 4.771;
    PLFLT pxly = 4.653;

    pls->graphx = TEXT_MODE;

/* Allocate and initialize device-specific data */

    pls->dev = calloc(1, (size_t) sizeof(TekDev));
    if (pls->dev == NULL)
	plexit("tek_init: Out of memory.");

    dev = (TekDev *) pls->dev;

    dev->curcolor = 1;
    dev->xold = PL_UNDEFINED;
    dev->yold = PL_UNDEFINED;

    plP_setpxl(pxlx, pxly);
    plP_setphy(xmin, xmax, ymin, ymax);

/* Terminal/file initialization */

    if (pls->termin) {
	pls->OutFile = stdout;
	tty_setup();
    }
    else {
	plFamInit(pls);
	plOpenFile(pls);
    }

    switch (pls->dev_minor) {
#ifdef PLD_tek4107
    case tek4107:
	pls->graphx = GRAPHICS_MODE;
	fprintf(pls->OutFile, "\033%%!0");	/* set tek mode */
	fprintf(pls->OutFile, "\033KN1");	/* clear the view */
	fprintf(pls->OutFile, "\033LZ");	/* clear dialog buffer */
	fprintf(pls->OutFile, "\033ML1");	/* set default color */
	break;
#endif	/* PLD_tek4107 */

/* A sneaky hack: VLT sometimes has leftover panel information, causing 
 * garbage at the beginning of a sequence of color fills.  Since 
 * there is no clear panel command, instead I set the fill color to the
 * same as background and issue an end panel command.
 */
#ifdef PLD_vlt
    case vlt:{
	char fillcol[4];
	tek_graph(pls);
	encode_int(fillcol, 0);
	fprintf(pls->OutFile, "\033MP%s\033LE", fillcol);
	break;
    }
#endif	/* PLD_vlt */

    default:
	tek_graph(pls);
    }

/* Initialize palette */

   if ( pls->color & 0x01 ) {
       printf("\033TM111");	/* Switch to RGB colors */
       setcmap(pls);
   }

/* Finish initialization */

    fprintf(pls->OutFile, VECTOR_MODE);	/* Enter vector mode */
    if (pls->termin)
	fprintf(pls->OutFile, CLEAR_VIEW);/* erase and home */

    fflush(pls->OutFile);
}