예제 #1
0
/* -----------------------------------
 * gap_detail_xml_align_get_values
 * -----------------------------------
 * This procedure is typically called
 * on the snapshot image created by the Player.
 * This image has one layer at the first snapshot
 * and each further snapshot adds one layer on top of the layerstack.
 *
 * The start is detected when the image has only one layer.
 * optionally the numer of layers can be limted
 * to 2 (or more) layers.
 */
void
gap_detail_xml_align_get_values(XmlAlignValues *xaVals)
{
  int l_len;

  /* init default values */
  xaVals->framePhase                 = DEFAULT_framePhase;
  xaVals->moveLogFile[0]             = '\0';

  l_len = gimp_get_data_size (GAP_DETAIL_TRACKING_XML_ALIGNER_PLUG_IN_NAME);
  if (l_len == sizeof(XmlAlignValues))
  {
    /* Possibly retrieve data from a previous interactive run */
    gimp_get_data (GAP_DETAIL_TRACKING_XML_ALIGNER_PLUG_IN_NAME, xaVals);
    
    if(gap_debug)
    {
      printf("gap_detail_xml_align_get_values FOUND data for key:%s\n"
        , GAP_DETAIL_TRACKING_XML_ALIGNER_PLUG_IN_NAME
        );
    }
  }

  if(gap_debug)
  {
    printf("gap_detail_xml_align_get_values:\n"
           "  framePhase:%d  moveLogFile:%s\n"
            , (int)xaVals->framePhase
            , xaVals->moveLogFile
            );
  }
  
}  /* end gap_detail_xml_align_get_values */
예제 #2
0
/* -----------------------------------
 * gap_detail_tracking_get_values
 * -----------------------------------
 * This procedure is typically called
 * on the snapshot image created by the Player.
 * This image has one layer at the first snapshot
 * and each further snapshot adds one layer on top of the layerstack.
 *
 * The start is detected when the image has only one layer.
 * optionally the numer of layers can be limted
 * to 2 (or more) layers.
 */
void
gap_detail_tracking_get_values(FilterValues *fiVals)
{
    int l_len;

    /* init default values */
    fiVals->refShapeRadius             = DEFAULT_refShapeRadius;
    fiVals->targetMoveRadius           = DEFAULT_targetMoveRadius;
    fiVals->loacteColodiffThreshold    = DEFAULT_loacteColodiffThreshold;
    fiVals->coordsRelToFrame1          = DEFAULT_coordsRelToFrame1;
    fiVals->offsX                      = DEFAULT_offsX;
    fiVals->offsY                      = DEFAULT_offsY;
    fiVals->offsRotate                 = DEFAULT_offsRotate;
    fiVals->enableScaling              = DEFAULT_enableScaling;
    fiVals->removeMidlayers            = DEFAULT_removeMidlayers;
    fiVals->bgLayerIsReference         = DEFAULT_bgLayerIsReference;
    fiVals->moveLogFile[0]             = '\0';

    l_len = gimp_get_data_size (GAP_DETAIL_TRACKING_PLUG_IN_NAME);
    if (l_len == sizeof(FilterValues))
    {
        /* Possibly retrieve data from a previous interactive run */
        gimp_get_data (GAP_DETAIL_TRACKING_PLUG_IN_NAME, fiVals);

        if(gap_debug)
        {
            printf("gap_detail_tracking_get_values FOUND data for key:%s\n"
                   , GAP_DETAIL_TRACKING_PLUG_IN_NAME
                  );
        }
    }

    if(gap_debug)
    {
        printf("gap_detail_tracking_get_values:\n"
               "  refShapeRadius:%d targetMoveRadius:%d locateColordiff:%.4f\n"
               "  coordsRelToFrame1:%d  offsX:%d offsY:%d removeMidlayers:%d bgLayerIsReference:%d\n"
               "  moveLogFile:%s\n"
               , (int)fiVals->refShapeRadius
               , (int)fiVals->targetMoveRadius
               , (float)fiVals->loacteColodiffThreshold
               , (int)fiVals->coordsRelToFrame1
               , (int)fiVals->offsX
               , (int)fiVals->offsY
               , (int)fiVals->removeMidlayers
               , (int)fiVals->bgLayerIsReference
               , fiVals->moveLogFile
              );
    }

}  /* end gap_detail_tracking_get_values */
예제 #3
0
/* -------------------------------
 * p_get_frameHistInfo
 * -------------------------------
 */
static void
p_get_frameHistInfo(FrameHistInfo *frameHistInfo)
{
    int l_len;

    frameHistInfo->workImageId = -1;
    frameHistInfo->frameNr = 0;
    frameHistInfo->startCoords.valid = FALSE;
    frameHistInfo->startCoords.px = 0;
    frameHistInfo->startCoords.py = 0;
    frameHistInfo->lostTraceCount = 0;

    l_len = gimp_get_data_size (GAP_DETAIL_FRAME_HISTORY_INFO);

    if(gap_debug)
    {
        printf("p_get_frameHistInfo: %s len:%d sizeof(FrameHistInfo):%d\n"
               , GAP_DETAIL_FRAME_HISTORY_INFO
               , (int)l_len
               , (int)sizeof(FrameHistInfo)
              );
    }


    if (l_len == sizeof(FrameHistInfo))
    {

        gimp_get_data(GAP_DETAIL_FRAME_HISTORY_INFO, frameHistInfo);

        if(gap_debug)
        {
            printf("p_get_frameHistInfo: %s  frameNr:%d px:%d py:%d valid:%d\n"
                   "                     prevPx:%d prevPy:%d prevValid:%d lostTraceCount:%d\n"
                   , GAP_DETAIL_FRAME_HISTORY_INFO
                   , (int)frameHistInfo->frameNr
                   , (int)frameHistInfo->startCoords.px
                   , (int)frameHistInfo->startCoords.py
                   , (int)frameHistInfo->startCoords.valid
                   , (int)frameHistInfo->prevCoords.px
                   , (int)frameHistInfo->prevCoords.py
                   , (int)frameHistInfo->prevCoords.valid
                   , (int)frameHistInfo->lostTraceCount
                  );
        }

    }

}  /* end p_get_frameHistInfo */
예제 #4
0
static gchar *
p_alloc_plugin_data(char *key)
{
   int l_len;
   gchar *l_plugin_data;
   
   l_len = gimp_get_data_size (key);
   if(l_len < 1)
   {
      fprintf(stderr, "ERROR: no stored data found for Key %s\n", key);
      return NULL;
   }
   l_plugin_data = g_malloc0(l_len+1);

   if(gap_debug) printf("DEBUG  Key:%s  plugin_data length %d\n", key, (int)l_len);
   return (l_plugin_data);
}
예제 #5
0
/* ============================================================================
 * p_get_data
 *    try to get the plugin's data (key is usually the name of the plugin)
 *    and check for the length of the retrieved data.
 * if all done OK return the length of the retrieved data,
 * return -1 in case of errors.
 * ============================================================================
 */
gint p_get_data(char *key)
{
   int l_len;

   l_len = gimp_get_data_size (key);
   if(l_len < 1)
   {
      fprintf(stderr, "ERROR: no stored data found for Key %s\n", key);
      return -1;
   }
   if(global_plugin_data)
   {
     g_free(global_plugin_data);
   }
   global_plugin_data = g_malloc0(l_len+1);
   gimp_get_data(key, global_plugin_data);

   if(gap_debug) printf("DEBUG p_get_data Key:%s  retrieved bytes %d\n", key, (int)l_len);
   return (l_len);
}
예제 #6
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[2]; /* Return values */
  GimpRunMode        run_mode;
  gint32             image_ID;
  gint32             drawable_ID;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
  gint32             image;
  GimpExportReturn   export = GIMP_EXPORT_CANCEL;
  GError            *error  = NULL;

  run_mode = param[0].data.d_int32;

  INIT_I18N ();

  /* Set up default return values */

  *nreturn_vals = 1;
  *return_vals  = values;
  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;

  if (strcmp (name, LOAD_PROC) == 0)
    {
      if (run_mode != GIMP_RUN_NONINTERACTIVE)
        {
          data_length = gimp_get_data_size (SAVE_PROC);
          if (data_length > 0)
            {
              palette_file = g_malloc (data_length);
              gimp_get_data (SAVE_PROC, palette_file);
            }
          else
            {
              palette_file = g_strdup ("*.kcf");
              data_length = strlen (palette_file) + 1;
            }
        }

      if (run_mode == GIMP_RUN_NONINTERACTIVE)
        {
          palette_file = param[3].data.d_string;
          data_length = strlen (palette_file) + 1;
        }
      else if (run_mode == GIMP_RUN_INTERACTIVE)
        {
          /* Let user choose KCF palette (cancel ignores) */
          if (need_palette (param[1].data.d_string))
            palette_dialog (_("Load KISS Palette"));

          gimp_set_data (SAVE_PROC, palette_file, data_length);
        }

      image = load_image (param[1].data.d_string, param[2].data.d_string,
                          &error);

      if (image != -1)
        {
          *nreturn_vals = 2;
          values[1].type         = GIMP_PDB_IMAGE;
          values[1].data.d_image = image;
        }
      else
        {
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }
  else if (strcmp (name, SAVE_PROC) == 0)
    {
      image_ID      = param[1].data.d_int32;
      drawable_ID   = param[2].data.d_int32;

      /*  eventually export the image */
      switch (run_mode)
	{
	case GIMP_RUN_INTERACTIVE:
	case GIMP_RUN_WITH_LAST_VALS:
	  gimp_ui_init (PLUG_IN_BINARY, FALSE);
	  export = gimp_export_image (&image_ID, &drawable_ID, "CEL",
				      (GIMP_EXPORT_CAN_HANDLE_RGB |
				       GIMP_EXPORT_CAN_HANDLE_ALPHA |
				       GIMP_EXPORT_CAN_HANDLE_INDEXED
				       ));
	  if (export == GIMP_EXPORT_CANCEL)
	    {
	      values[0].data.d_status = GIMP_PDB_CANCEL;
	      return;
	    }
	  break;
	default:
	  break;
	}
예제 #7
0
static void run ( const gchar *name, gint nparams, const GimpParam *param,
                  gint *nreturn_vals, GimpParam **return_vals)
{
  static GimpParam values[3];
  GimpRunMode run_mode;
  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  SeparateContext mysc;
  //enum separate_function func = SEP_NONE;
  run_mode = param[0].data.d_int32;


  /* setup for localization */
  INIT_I18N ();

  cmsErrorAction( LCMS_ERROR_IGNORE );

  mysc.filename = NULL;
  if( nparams != ( run_mode == GIMP_RUN_NONINTERACTIVE ? 2 : 1 ) )
    status = GIMP_PDB_CALLING_ERROR;
  else if( run_mode == GIMP_RUN_NONINTERACTIVE ) {
    if( param[1].type != GIMP_PDB_STRING || strlen( param[1].data.d_string ) == 0 )
      status = GIMP_PDB_CALLING_ERROR;
    else
      mysc.filename = g_strdup( param[1].data.d_string );
  } else {
    gint size = gimp_get_data_size( "plug-in-separate-import/lastpath" );
    if( size ) {
      mysc.filename = g_malloc( size );
      gimp_get_data( "plug-in-separate-import/lastpath", mysc.filename );
    }
  }

  if( status == GIMP_PDB_SUCCESS && ( run_mode == GIMP_RUN_NONINTERACTIVE || separate_import_dialog( &mysc ) ) ) {
    gint i, j, x, y;
    TIFF *in;
    guint32 width, height, stripSize, stripCount, stripHeight;
    gint16 bps, spp, step, planerConfig, photometric, inkset, resolutionUnit;
    float xres, yres;
    const gchar *layerNames[] = { "C", "M", "Y", "K" };
    guchar *buf, *maskbuf[4], *srcbuf, *destbuf[4], *iccProfile;
    gint32 layers[5], masks[4];
    GimpDrawable *drw[4];
    GimpPixelRgn rgn[4];
    GimpRGB primaries[4] = { { .180, .541, .870, 1.0 },
                             { .925, .149, .388, 1.0 },
                             { .929, .862, .129, 1.0 },
                             { 0, 0, 0, 1.0 }  };

    gchar *str = NULL;
    gchar *baseName = g_path_get_basename( gimp_filename_to_utf8( mysc.filename ) );

#ifdef G_OS_WIN32
    {
      gchar *_filename = NULL; // win32 filename encoding(not UTF-8)
      _filename = g_win32_locale_filename_from_utf8( mysc.filename );
      in = TIFFOpen( _filename ? _filename : mysc.filename, "r" );
      g_free( _filename );
    }
#else
    in = TIFFOpen( mysc.filename, "r" );
#endif

    if( !in ) {
      str = g_strdup_printf( _( "Cannot open : \"%s\"" ), baseName );
      gimp_message( str );
      g_free( str );
      status = GIMP_PDB_EXECUTION_ERROR;
    } else {
      if( ( TIFFGetField( in, TIFFTAG_BITSPERSAMPLE, &bps ) == FALSE || ( bps != 8 && bps != 16 ) ) ||
          ( TIFFGetField( in, TIFFTAG_SAMPLESPERPIXEL, &spp ) == FALSE || spp != 4 ) ||
          ( TIFFGetField( in, TIFFTAG_PHOTOMETRIC, &photometric ) == FALSE || photometric != PHOTOMETRIC_SEPARATED ) ||
          ( TIFFGetField( in, TIFFTAG_PLANARCONFIG, &planerConfig ) == FALSE || planerConfig != PLANARCONFIG_CONTIG ) ||
          ( TIFFGetField( in, TIFFTAG_INKSET, &inkset ) == TRUE && inkset != INKSET_CMYK ) ) {
        str = g_strdup_printf( _( "\"%s\" is unsupported." ), baseName );
        gimp_message( str );
        g_free( str );
        status = GIMP_PDB_EXECUTION_ERROR;
      } else {
        stripCount = TIFFNumberOfStrips( in );
        stripSize = TIFFStripSize( in );
        TIFFGetField( in, TIFFTAG_IMAGEWIDTH, &width );
        TIFFGetField( in, TIFFTAG_IMAGELENGTH, &height );
        TIFFGetField( in, TIFFTAG_ROWSPERSTRIP, &stripHeight );
        TIFFGetField( in, TIFFTAG_RESOLUTIONUNIT, &resolutionUnit );
        TIFFGetField( in, TIFFTAG_XRESOLUTION, &xres );
        TIFFGetField( in, TIFFTAG_YRESOLUTION, &yres );

#if 0
        str = g_strdup_printf( "Photometric : %d  BPS : %d  SPP : %d\nInkset : %d  StripCount : %d", photometric, bps, spp, inkset, stripCount );
        gimp_message( str );
        g_free( str );
#endif

        step = ( bps == 16 ) ? 2 : 1;

        buf = g_malloc( stripSize );

        values[1].data.d_image = gimp_image_new( width, height, GIMP_RGB );
        gimp_image_set_resolution( values[1].data.d_image, xres, yres );
        gimp_context_push();
        for( i = 0; i < 4; i++ ) {
          layers[i] = gimp_layer_new( values[1].data.d_image, layerNames[i], width, height, GIMP_RGBA_IMAGE, 100.0, GIMP_DARKEN_ONLY_MODE );
          gimp_context_set_foreground( &primaries[i] );
          gimp_drawable_fill( layers[i], GIMP_FOREGROUND_FILL );
          gimp_image_add_layer( values[1].data.d_image, layers[i], i );
          masks[i] = gimp_layer_create_mask( layers[i], GIMP_ADD_BLACK_MASK );
          gimp_layer_add_mask( layers[i], masks[i] );
          drw[i] = gimp_drawable_get( masks[i] );
          maskbuf[i] = g_malloc( width * stripHeight );
        }
        gimp_context_pop();
        layers[4] = gimp_layer_new( values[1].data.d_image, _( "Background" ), width, height, GIMP_RGB_IMAGE, 100.0, GIMP_NORMAL_MODE );
        gimp_drawable_fill( layers[4], GIMP_WHITE_FILL );
        gimp_image_add_layer( values[1].data.d_image, layers[4], 4 );

        str = g_strdup_printf( _( "Reading \"%s\"..." ), baseName );
        gimp_progress_init( str );
        g_free( str );

        for( i = 0; i < stripCount; i++ ) {
          guint32 size = TIFFReadEncodedStrip( in, i, buf, stripSize );
          guint32 rowCount = ( size < stripSize ? height % stripHeight : stripHeight );
          srcbuf = buf;
          if( bps == 16 )
            srcbuf++;
          for( j = 0; j < 4; j++ ) {
            gimp_pixel_rgn_init( &( rgn[j] ), drw[j],
                                 0, stripHeight * i, width, rowCount,
                                 FALSE, FALSE );
            destbuf[j] = maskbuf[j];
          }
          for( y = 0; y < rowCount; y++ ) {
            for( x = 0; x < width; x++ ) {
              *destbuf[0]++ = *srcbuf;
              srcbuf += step;
              *destbuf[1]++ = *srcbuf;
              srcbuf += step;
              *destbuf[2]++ = *srcbuf;
              srcbuf += step;
              *destbuf[3]++ = *srcbuf;
              srcbuf += step;
              //srcbuf += spp > 4 ? spp - 4 : 0;
            }
          }
          gimp_pixel_rgn_set_rect( &( rgn[0] ), maskbuf[0], 0, stripHeight * i, width, rowCount );
          gimp_pixel_rgn_set_rect( &( rgn[1] ), maskbuf[1], 0, stripHeight * i, width, rowCount );
          gimp_pixel_rgn_set_rect( &( rgn[2] ), maskbuf[2], 0, stripHeight * i, width, rowCount );
          gimp_pixel_rgn_set_rect( &( rgn[3] ), maskbuf[3], 0, stripHeight * i, width, rowCount );
          gimp_progress_update( (gdouble)i / stripCount );
        }
        g_free( buf );
        for( i = 0; i < 4; i++ ) {
          g_free( maskbuf[i] );
          gimp_drawable_detach( drw[i] );
        }

#ifdef ENABLE_COLOR_MANAGEMENT
        if ( TIFFGetField( in, TIFFTAG_ICCPROFILE, &width, &iccProfile ) ) {
          GimpParasite *parasite;

          parasite = gimp_parasite_new( CMYKPROFILE, 0, width, iccProfile );
          gimp_image_parasite_attach( values[1].data.d_image, parasite );
          gimp_parasite_free( parasite );

          //g_free( iccProfile ); // This causes clash on TIFFClose( in ).
        }
#endif
      }
      TIFFClose( in );
    }
    g_free( baseName );
  } else
    status = GIMP_PDB_CANCEL;

  *return_vals = values;
  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
  if( status == GIMP_PDB_SUCCESS ) {
    *nreturn_vals = 2;
    values[1].type = GIMP_PDB_IMAGE;
    if( run_mode != GIMP_RUN_NONINTERACTIVE ) {
      gimp_image_undo_enable( values[1].data.d_image );
      gimp_display_new( values[1].data.d_image );
      gimp_displays_flush();
    }
    gimp_set_data( "plug-in-separate-import/lastpath", mysc.filename, strlen( mysc.filename ) + 1 );
  } else
    *nreturn_vals = 1;

  g_free( mysc.filename );
}
예제 #8
0
// Run the plugin
static void
run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals)
{
	// Return values
  static GimpParam values[1];

  gint sel_x1, sel_y1, sel_x2, sel_y2, w, h, padding;
	PluginData         pd;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;

  *nreturn_vals = 1;
  *return_vals  = values;

  if (param[0].type!= GIMP_PDB_INT32) 
	  status=GIMP_PDB_CALLING_ERROR;
  if (param[2].type!=GIMP_PDB_DRAWABLE)
	  status=GIMP_PDB_CALLING_ERROR;

  run_mode = (GimpRunMode) param[0].data.d_int32;
	
	pd.drawable = gimp_drawable_get(param[2].data.d_drawable);
	gimp_drawable_mask_bounds(pd.drawable->drawable_id, &sel_x1, &sel_y1, &sel_x2, &sel_y2);
	pd.selection_width = sel_x2 - sel_x1;
  pd.selection_height = sel_y2 - sel_y1;
  pd.selection_offset_x = sel_x1;
  pd.selection_offset_y = sel_y1;
  pd.image_width = gimp_drawable_width(pd.drawable->drawable_id);
  pd.image_height = gimp_drawable_height(pd.drawable->drawable_id);
  pd.channel_count = gimp_drawable_bpp(pd.drawable->drawable_id);

  pd.point_grabbed = -1;

	if (run_mode == GIMP_RUN_INTERACTIVE)
	{
		// Interactive call with dialog
		dialog(&pd);
		if (pd.curve_user.count > 0)
		{
			gimp_set_data (PLUG_IN_BINARY, pd.curve_user.user_points, sizeof (GdkPoint) * pd.curve_user.count);
		}
	}
	else if (run_mode == GIMP_RUN_WITH_LAST_VALS)
	{
		// Read a saved curve and apply it
		fft_prepare(&pd);
		gimp_get_data(PLUG_IN_BINARY, pd.curve_user.user_points);
		pd.curve_user.count = gimp_get_data_size(PLUG_IN_BINARY) / sizeof (GdkPoint);
		gimp_pixel_rgn_init(&pd.region, pd.drawable, 0, 0, pd.image_width, pd.image_height, TRUE, TRUE);
		fft_apply(&pd);
		gimp_pixel_rgn_set_rect(&pd.region, pd.img_pixels, 0, 0, pd.image_width, pd.image_height);
		gimp_drawable_flush(pd.drawable);
		gimp_drawable_merge_shadow(pd.drawable->drawable_id, TRUE);
		gimp_drawable_update(pd.drawable->drawable_id, pd.selection_offset_x, pd.selection_offset_y, pd.selection_width, pd.selection_height);
		fft_destroy(&pd);
		gimp_displays_flush();
	}
	else
	{
	  status = GIMP_PDB_CALLING_ERROR;	
	}
  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;
  gimp_drawable_detach(pd.drawable);
}
예제 #9
0
void
gimp_lastval_desc_update(void)
{
  gchar *fname;
  gchar *file_buff;
  gchar *l_keyname;
  gchar *key_description;
  gint   arg_cnt;
  gint   max_expected_argc;
  GimpLastvalDescType *lastval_desc_arr;
  gchar   *ptr;
  gchar   *next_line_ptr;
  gint32 l_idx;
  gint32 l_filesize;
  time_t   l_timestamp;
  GStatBuf stat_buf;
  
  arg_cnt = 0;

  fname = gimp_lastval_desc_filename();  

  /* check timestamps */
  if(gimp_get_data_size(TIMESTAMP_DESCFILE_CHECKED) > 1)
  {     
     gimp_get_data(TIMESTAMP_DESCFILE_CHECKED, &l_timestamp);
     if(g_stat(fname, &stat_buf) == 0)
     {
        if(l_timestamp > stat_buf.st_mtime)
        {
           /* file last modification is older than timestamp of last check
            * (we dont need to read the file again)
            */
           g_free(fname);
           return;
        }
     }
     else
     {
        /* file not found, no need to continue */
        g_free(fname);
        return;
     }
  }
  l_timestamp = gap_base_get_current_time();
  gimp_set_data(TIMESTAMP_DESCFILE_CHECKED, &l_timestamp, sizeof(l_timestamp));
  
  p_init_token_table();
  
  /* read all descriptions from file  */
  file_buff = p_load_lastval_desc_file(fname);
  if(file_buff == NULL)
  {
    return;
  }
  l_filesize = strlen(file_buff);


  /* set/replace all descriptions in memory for the current gimp session */
  
  max_expected_argc = 10 + (l_filesize / 7);
  lastval_desc_arr = g_new(GimpLastvalDescType, max_expected_argc);
  l_keyname = NULL;
  key_description = g_strdup(" ");
  
  for(ptr = file_buff; *ptr != '\0'; ptr = next_line_ptr)
  {      
    /* skip blanks */
    while (*ptr == ' ' || *ptr == '\t') { ptr++;}

    /* findout start on next line (and terminate the current line with '\0') */
    next_line_ptr = ptr;
    while (*next_line_ptr != '\0')
    {
      if(*next_line_ptr == '\n')
      {
        *next_line_ptr = '\0';
        next_line_ptr++;
        break;
      }
      next_line_ptr++;
    }


    /* printf("LINE:%s\n", ptr); */

    /* ignore empty lines and comment lines */
    if ((*ptr != '\n')
    &&  (*ptr != '\0')
    &&  (*ptr != '#'))
    {
      if (*ptr == '"')
      {
        l_idx = 1;
        l_keyname = &ptr[1];
        while (1)
        {
          if (ptr[l_idx] == '"' || ptr[l_idx] == '\n' || ptr[l_idx] == '\0') 
          {
             ptr[l_idx] = '\0';
             g_free(key_description);
             /* printf("KEY:%s\n", l_keyname); */
             key_description = gimp_lastval_desc_keyname(l_keyname);
             break;
          }
          l_idx++;
        }
      }
      else
      {
        for(l_idx=0; l_idx <= GIMP_LASTVAL_END; l_idx++)
        {
          char *l_token;

          l_token = g_strdup_printf("%s;", token_tab[l_idx].token);
          if(0 == strncmp(ptr, l_token, strlen(l_token)))
          {
             /* found a matching datatype token */
             if(strcmp("END;",l_token) == 0)
             {
               lastval_desc_arr[arg_cnt].lastval_type = GIMP_LASTVAL_END;
               lastval_desc_arr[arg_cnt].offset = 0;
               lastval_desc_arr[arg_cnt].elem_size = 0;
               lastval_desc_arr[arg_cnt].iter_flag = 0;
               lastval_desc_arr[arg_cnt].elem_name[0] = '\0';
               arg_cnt++;
               /* if it is the END of description block store array in memory */
               /* printf("SET_DATA:%s\n", key_description); */
               gimp_set_data(key_description, lastval_desc_arr, sizeof(GimpLastvalDescType) * arg_cnt);
               arg_cnt = 0;
               g_free(key_description);
               key_description = g_strdup(" ");
             }
             else
             {
               int  l_nscan;

               lastval_desc_arr[arg_cnt].elem_name[0] = '\0';
               lastval_desc_arr[arg_cnt].lastval_type = token_tab[l_idx].lastval_type;
               l_nscan = sscanf(&ptr[strlen(l_token)], "%d;%d;%d;%50s"
                     , &lastval_desc_arr[arg_cnt].offset
                     , &lastval_desc_arr[arg_cnt].elem_size
                     , &lastval_desc_arr[arg_cnt].iter_flag
                     ,  lastval_desc_arr[arg_cnt].elem_name
                     );
               if(l_nscan != 3 && l_nscan != 4)
               {
                  printf("ERROR while scanning datatype %s in file %s\n", ptr, fname);
               }
               else
               {
                 arg_cnt++;
               }
             }
             break;
          }
          g_free(l_token);
        }
        if (l_idx > GIMP_LASTVAL_END)
        {
           printf("ERROR unknown datatype %s in file %s  %d  %d\n", ptr, fname, l_idx, GIMP_LASTVAL_END);
        }
      }
    }
  }

  g_free(key_description);
  g_free(lastval_desc_arr);
  g_free(fname);
}       /* end gimp_lastval_desc_update */
예제 #10
0
파일: main.c 프로젝트: GNOME/gimp-pspi
static GimpPDBStatusType
run_pspi_settings (gint             n_params, 
		   const GimpParam *param)
{
  GimpRunMode run_mode = param[0].data.d_int32;
  GString *sp;
  int i;
  
  switch (run_mode)
    {
    case GIMP_RUN_NONINTERACTIVE:
      if (n_params != pspi_settings_nargs)
	return GIMP_PDB_CALLING_ERROR;

      if (param[1].data.d_int32 <= 0 || param[1].data.d_int32 > 10)
	return GIMP_PDB_CALLING_ERROR;

      sp = g_string_new ("");
      for (i = 0; i < param[1].data.d_int32; i++)
	{
	  if (sp->len > 0)
	    g_string_append_c (sp, G_SEARCHPATH_SEPARATOR);
	  g_string_append (sp, param[2].data.d_stringarray[i]);
	  search_path = sp->str;
	}
      break;

    case GIMP_RUN_INTERACTIVE:
      /*  Possibly retrieve data  */
      i = gimp_get_data_size (PSPI_PATH_TOKEN);
      if (i > 0)
	{
	  search_path = g_malloc (i);
	  gimp_get_data (PSPI_PATH_TOKEN, search_path);
	}
      else
	{
	  search_path = gimp_gimprc_query (PSPI_PATH_TOKEN);
	  if (search_path == NULL)
	    search_path = g_strdup ("");
	}

      if (! pspi_settings_dialog (&search_path))
	return GIMP_PDB_CANCEL;
      gimp_message (_("The new search path will be used next time GIMP is started"));
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      break;

    default:
      break;
    }

  if (search_path == NULL)
    search_path = g_strdup ("");
  gimp_set_data (PSPI_PATH_TOKEN, search_path, strlen (search_path) + 1);
  gimp_gimprc_set (PSPI_PATH_TOKEN, search_path);

  return GIMP_PDB_SUCCESS;
}
예제 #11
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  gint32             image_ID;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status    = GIMP_PDB_SUCCESS;
  gboolean           no_dialog;

  INIT_I18N ();
  gegl_init (NULL, NULL);

  run_mode = param[0].data.d_int32;

  no_dialog = (strcmp (name, "plug-in-sel2path") == 0);

  *nreturn_vals = 1;
  *return_vals = values;

  values[0].type = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  image_ID = param[1].data.d_image;
  if (image_ID < 0)
    {
      g_warning ("plug-in-sel2path needs a valid image ID");
      return;
    }

  if (gimp_selection_is_empty (image_ID))
    {
      g_message (_("No selection to convert"));
      return;
    }

  fit_set_default_params (&selVals);

  if (!no_dialog)
    {
      switch (run_mode)
        {
        case GIMP_RUN_INTERACTIVE:
          if (gimp_get_data_size ("plug-in-sel2path-advanced") > 0)
            {
              gimp_get_data ("plug-in-sel2path-advanced", &selVals);
            }

          if (!sel2path_dialog (&selVals))
            return;

          /* Get the current settings */
          fit_set_params (&selVals);
          break;

        case GIMP_RUN_NONINTERACTIVE:
          if (nparams != 23)
            status = GIMP_PDB_CALLING_ERROR;

          if (status == GIMP_PDB_SUCCESS)
            {
              selVals.align_threshold             =  param[3].data.d_float;
              selVals.corner_always_threshold     =  param[4].data.d_float;
              selVals.corner_surround             =  param[5].data.d_int8;
              selVals.corner_threshold            =  param[6].data.d_float;
              selVals.error_threshold             =  param[7].data.d_float;
              selVals.filter_alternative_surround =  param[8].data.d_int8;
              selVals.filter_epsilon              =  param[9].data.d_float;
              selVals.filter_iteration_count      = param[10].data.d_int8;
              selVals.filter_percent              = param[11].data.d_float;
              selVals.filter_secondary_surround   = param[12].data.d_int8;
              selVals.filter_surround             = param[13].data.d_int8;
              selVals.keep_knees                  = param[14].data.d_int8;
              selVals.line_reversion_threshold    = param[15].data.d_float;
              selVals.line_threshold              = param[16].data.d_float;
              selVals.reparameterize_improvement  = param[17].data.d_float;
              selVals.reparameterize_threshold    = param[18].data.d_float;
              selVals.subdivide_search            = param[19].data.d_float;
              selVals.subdivide_surround          = param[20].data.d_int8;
              selVals.subdivide_threshold         = param[21].data.d_float;
              selVals.tangent_surround            = param[22].data.d_int8;
              fit_set_params (&selVals);
            }
          break;

        case GIMP_RUN_WITH_LAST_VALS:
          if(gimp_get_data_size ("plug-in-sel2path-advanced") > 0)
            {
              gimp_get_data ("plug-in-sel2path-advanced", &selVals);

              /* Set up the last values */
              fit_set_params (&selVals);
            }
          break;

        default:
          break;
        }
    }

  sel2path (image_ID);
  values[0].data.d_status = status;

  if (status == GIMP_PDB_SUCCESS)
    {
      dialog_print_selVals(&selVals);
      if (run_mode == GIMP_RUN_INTERACTIVE && !no_dialog)
        gimp_set_data ("plug-in-sel2path-advanced", &selVals, sizeof(SELVALS));
    }
}