Esempio n. 1
0
void
c_plscmap0(PLINT *r, PLINT *g, PLINT *b, PLINT ncol0)
{
    int i;

    plscmap0n(ncol0);

    for (i = 0; i < plsc->ncol0; i++) {
	if ((r[i] < 0 || r[i] > 255) ||
	    (g[i] < 0 || g[i] > 255) ||
	    (b[i] < 0 || b[i] > 255)) {

	    char buffer[256];
	    sprintf(buffer, "plscmap0: Invalid RGB color: %d, %d, %d",
		    (int) r[i], (int) g[i], (int) b[i]);
	    plabort(buffer);
	    return;
	}

	plsc->cmap0[i].r = r[i];
	plsc->cmap0[i].g = g[i];
	plsc->cmap0[i].b = b[i];
    }

    if (plsc->level > 0)
	plP_state(PLSTATE_CMAP0);
}
Esempio n. 2
0
void
c_plscol0(PLINT icol0, PLINT r, PLINT g, PLINT b)
{
    if (plsc->cmap0 == NULL)
	plscmap0n(0);

    if (icol0 < 0 || icol0 >= plsc->ncol0) {
	char buffer[256];
	sprintf(buffer, "plscol0: Illegal color table value: %d", (int) icol0);
	plabort(buffer);
	return;
    }
    if ((r < 0 || r > 255) || (g < 0 || g > 255) || (b < 0 || b > 255)) {
	char buffer[256];
	sprintf(buffer, "plscol0: Invalid RGB color: %d, %d, %d",
		(int) r, (int) g, (int) b);
	plabort(buffer);
	return;
    }

    plsc->cmap0[icol0].r = r;
    plsc->cmap0[icol0].g = g;
    plsc->cmap0[icol0].b = b;

    if (plsc->level > 0)
	plP_state(PLSTATE_CMAP0);
}
Esempio n. 3
0
void plD_tidy_png(PLStream *pls)
{

#ifdef HAVE_FREETYPE
   if (pls->dev_text)
     {
	FT_Data *FT=(FT_Data *)pls->FT;
	plscmap0n(FT->ncol0_org);
	plD_FreeType_Destroy(pls);
     }
#endif

   fclose(pls->OutFile);
   free_mem(pls->dev);
}
Esempio n. 4
0
static void init_freetype_lv2( PLStream *pls )
{
  // Log_Verbose( "init_freetype_lv2" );

  wxPLDevBase *dev=(wxPLDevBase *)pls->dev;
  FT_Data *FT=(FT_Data *)pls->FT;

  FT->scalex=dev->scalex;
  FT->scaley=dev->scaley;
  FT->ymax=dev->height;
  FT->invert_y=1;
  FT->smooth_text=0;

  if ((FT->want_smooth_text==1)&&(FT->BLENDED_ANTIALIASING==0))    /* do we want to at least *try* for smoothing ? */
  {
    FT->ncol0_org=pls->ncol0;                                   /* save a copy of the original size of ncol0 */
    FT->ncol0_xtra=16777216-(pls->ncol1+pls->ncol0);            /* work out how many free slots we have */
    FT->ncol0_width=FT->ncol0_xtra/(pls->ncol0-1);              /* find out how many different shades of anti-aliasing we can do */
    if (FT->ncol0_width>4)     /* are there enough colour slots free for text smoothing ? */
       {
        if (FT->ncol0_width>max_number_of_grey_levels_used_in_text_smoothing)
           FT->ncol0_width=max_number_of_grey_levels_used_in_text_smoothing;                 /* set a maximum number of shades */
        plscmap0n(FT->ncol0_org+(FT->ncol0_width*pls->ncol0));      /* redefine the size of cmap0 */
    /* the level manipulations are to turn off the plP_state(PLSTATE_CMAP0)
    * call in plscmap0 which (a) leads to segfaults since the GD image is
    * not defined at this point and (b) would be inefficient in any case since
    * setcmap is always called later (see plD_bop_png) to update the driver
    * color palette to be consistent with cmap0. */
         {
          PLINT level_save;
          level_save = pls->level;
          pls->level = 0;
          pl_set_extended_cmap0(pls, FT->ncol0_width, FT->ncol0_org); /* call the function to add the extra cmap0 entries and calculate stuff */
          pls->level = level_save;
         }
        FT->smooth_text=1;      /* Yippee ! We had success setting up the extended cmap0 */
      }
    else
      plwarn("Insufficient colour slots available in CMAP0 to do text smoothing.");
  } else if ((FT->want_smooth_text==1)&&(FT->BLENDED_ANTIALIASING==1))    /* If we have a truecolour device, we wont even bother trying to change the palette */
   {
     FT->smooth_text=1;
   }
}
Esempio n. 5
0
int
main( int argc, char *argv[] )
{
    int i, j;

    plparseopts( &argc, argv, PL_PARSE_FULL );

    plinit();

    pladv( 0 );
    plvpor( 0.0, 1.0, 0.0, 1.0 );
    plwind( 0.0, 1.0, 0.0, 1.0 );
    plcol0( 0 );
    plbox( "", 1.0, 0, "", 1.0, 0 );

    plscmap0n( 7 );
    plscmap0( red, green, blue, 7 );

    plschr( 0, 4.0 );
    plfont( 1 );

    for ( i = 0; i < 4; i++ )
    {
        plcol0( i + 1 );
        plfill( 4, px, py );

        for ( j = 0; j < 4; j++ )
            py [j] += 1.0 / 4.0;
    }

    plcol0( 0 );
    for ( i = 0; i < 12; i++ )
        plptex( sx [i], sy [i], 1.0, 0.0, 0.5, peace [i] );


    plend();
    exit( 0 );
}
Esempio n. 6
0
void
c_plgcol0(PLINT icol0, PLINT *r, PLINT *g, PLINT *b)
{
    if (plsc->cmap0 == NULL)
	plscmap0n(0);

    *r = -1;
    *g = -1;
    *b = -1;

    if (icol0 < 0 || icol0 > plsc->ncol0) {
	char buffer[256];
	sprintf(buffer, "plgcol0: Invalid color index: %d", (int) icol0);
	plabort(buffer);
	return;
    }

    *r = plsc->cmap0[icol0].r;
    *g = plsc->cmap0[icol0].g;
    *b = plsc->cmap0[icol0].b;

    return;
}
Esempio n. 7
0
/*--------------------------------------------------------------------------
 *  void plD_tidy_wxwidgets( PLStream *pls )
 *
 *  This function is called, if all plots are done.
 *--------------------------------------------------------------------------*/
void plD_tidy_wxwidgets( PLStream *pls )
{
  // Log_Verbose( "plD_tidy_wxwidgets()" );

  wxPLDevBase* dev = (wxPLDevBase*)pls->dev;

#ifdef HAVE_FREETYPE
  if( dev->freetype ) {
    FT_Data *FT=(FT_Data *)pls->FT;
    plscmap0n( FT->ncol0_org );
    plD_FreeType_Destroy( pls );
  }
#endif

  if( dev->ownGUI ) {
    wxPLGetApp().RemoveFrame( dev->m_frame );
		if( !wxPLGetApp().FrameCount() )
    	wxUninitialize();
  }

  delete dev;
  pls->dev=NULL;  /* since in plcore.c pls->dev is free_mem'd */
}