Beispiel #1
0
static gint32
load_image (const gchar  *uri,
            GimpRunMode   run_mode,
            GError      **error)
{
  gchar    *tmpname    = NULL;
  gint32    image_ID   = -1;
  gboolean  name_image = FALSE;

  tmpname = get_temp_name (uri, &name_image);

  if (uri_backend_load_image (uri, tmpname, run_mode, error))
    {
      image_ID = gimp_file_load (run_mode, tmpname, tmpname);

      if (image_ID != -1)
        {
          if (name_image)
            gimp_image_set_filename (image_ID, uri);
          else
            gimp_image_set_filename (image_ID, "");
        }
      else
        {
          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                       "%s", gimp_get_pdb_error ());
        }
    }

  g_unlink (tmpname);
  g_free (tmpname);

  return image_ID;
}
Beispiel #2
0
GimpPDBStatusType
screenshot_osx_shoot (ScreenshotValues *shootvals,
                      GdkScreen        *screen,
                      gint32           *image_ID)
{
  gchar *mode    = " ";
  gchar *delay   = NULL;
  gchar *cursor  = " ";
  gchar *command = NULL;

  switch (shootvals->shoot_type)
    {
    case SHOOT_REGION:
      mode = "-is";
      break;

    case SHOOT_WINDOW:
      mode = "-iwo";
      if (shootvals->decorate)
        mode = "-iw";
      break;

    case SHOOT_ROOT:
      mode = " ";
      break;

    default:
      break;
    }

  delay = g_strdup_printf ("-T %i", shootvals->select_delay);

  if (shootvals->show_cursor)
    cursor = "-C";

  command = g_strjoin (" ",
                       "/usr/sbin/screencapture",
                       mode,
                       cursor,
                       delay,
                       "/tmp/screenshot.png",
                       NULL);

  system ((const char *) command);

  g_free (command);
  g_free (delay);

  *image_ID = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
                              "/tmp/screenshot.png", "/tmp/screenshot.png");
  gimp_image_set_filename (*image_ID, "screenshot.png");

  return GIMP_PDB_SUCCESS;
}
Beispiel #3
0
static gint32
load_image (const gchar  *uri,
            GimpRunMode   run_mode,
            GError      **error)
{
  gint32    image_ID   = -1;
  gboolean  name_image = FALSE;
  gchar    *tmpname;
  gboolean  mapped     = FALSE;

  tmpname = uri_backend_map_image (uri, run_mode);

  if (tmpname)
    {
      mapped = TRUE;
    }
  else
    {
      tmpname = get_temp_name (uri, &name_image);

      if (! uri_backend_load_image (uri, tmpname, run_mode, error))
        return -1;
    }

  image_ID = gimp_file_load (run_mode, tmpname, tmpname);

  if (image_ID != -1)
    {
      if (mapped || name_image)
        gimp_image_set_filename (image_ID, uri);
      else
        gimp_image_set_filename (image_ID, "");
    }
  else
    {
      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
                   "%s", gimp_get_pdb_error ());
    }

  if (! mapped)
    g_unlink (tmpname);

  g_free (tmpname);

  return image_ID;
}
void bimp_apply_drawable_manipulations(image_output imageout, gchar* orig_filename, gchar* orig_basename)
{
    imageout->image_id = gimp_file_load(GIMP_RUN_NONINTERACTIVE, orig_filename, orig_basename); // load file and get image id 
    // LOAD ERROR CHECK HERE 
    g_print("Image ID is %d\n", imageout->image_id);
    
    imageout->drawable_ids = gimp_image_get_layers(imageout->image_id, &imageout->drawable_count); // get all drawables
    g_print("Total drawables count: %d\n", imageout->drawable_count);
    
    // apply all the intermediate manipulations 
    g_slist_foreach(bimp_selected_manipulations, (GFunc)apply_manipulation, imageout);
    
    //  watermark at last 
    if(list_contains_watermark) {
        g_print("Applying WATERMARK...\n");
        apply_watermark((watermark_settings)(bimp_list_get_manip(MANIP_WATERMARK))->settings, imageout);
    }
}
Beispiel #5
0
void bimp_apply_drawable_manipulations(image_output imageout, gchar* orig_filename, gchar* orig_basename)
{
    imageout->image_id = gimp_file_load(GIMP_RUN_NONINTERACTIVE, orig_filename, orig_basename); /* load file and get image id */
    /* LOAD ERROR CHECK HERE */
    g_print("Image ID is %d\n", imageout->image_id);

    imageout->drawable_id = gimp_image_merge_visible_layers(imageout->image_id, GIMP_CLIP_TO_IMAGE); /* merge levels and get drawable id */
    gimp_layer_add_alpha (imageout->drawable_id);
    g_print("Drawable ID is %d\n", imageout->drawable_id);

    /* apply all the intermediate manipulations */
    g_slist_foreach(bimp_selected_manipulations, (GFunc)apply_manipulation, imageout);

    /*  watermark at last */
    if(list_contains_watermark) {
        g_print("Applying WATERMARK...\n");
        apply_watermark((watermark_settings)(bimp_list_get_manip(MANIP_WATERMARK))->settings, imageout);
    }
}
Beispiel #6
0
GimpPDBStatusType
screenshot_osx_shoot (ScreenshotValues  *shootvals,
                      GdkScreen         *screen,
                      gint32            *image_ID,
                      GError           **error)
{
  const gchar *mode    = " ";
  const gchar *cursor  = " ";
  gchar       *delay   = NULL;
  gchar       *filename;
  gchar       *quoted;
  gchar       *command = NULL;

  switch (shootvals->shoot_type)
    {
    case SHOOT_REGION:
      mode = "-is";
      break;

    case SHOOT_WINDOW:
      if (shootvals->decorate)
        mode = "-iwo";
      else
        mode = "-iw";
      break;

    case SHOOT_ROOT:
      mode = " ";
      if (shootvals->show_cursor)
        cursor = "-C";
      break;

    default:
      g_return_val_if_reached (GIMP_PDB_CALLING_ERROR);
      break;
    }

  delay = g_strdup_printf ("-T %i", shootvals->select_delay);

  filename = gimp_temp_name ("png");
  quoted   = g_shell_quote (filename);

  command = g_strjoin (" ",
                       "/usr/sbin/screencapture",
                       mode,
                       cursor,
                       delay,
                       quoted,
                       NULL);

  g_free (quoted);
  g_free (delay);

  if (system ((const char *) command) == EXIT_SUCCESS)
    {
      *image_ID = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
                                  filename, filename);
      gimp_image_set_filename (*image_ID, "screenshot.png");

      g_unlink (filename);
      g_free (filename);
      g_free (command);

      return GIMP_PDB_SUCCESS;
   }

  g_free (command);
  g_free (filename);

  return GIMP_PDB_EXECUTION_ERROR;
}