264 lines
8.3 KiB
C
264 lines
8.3 KiB
C
/* LIBPIKA - The PIKA Library
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
|
*
|
|
* pikafile_pdb.c
|
|
*
|
|
* This library is free software: you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 3 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see
|
|
* <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl */
|
|
|
|
#include "config.h"
|
|
|
|
#include "stamp-pdbgen.h"
|
|
|
|
#include "pika.h"
|
|
|
|
|
|
/**
|
|
* SECTION: pikafile
|
|
* @title: pikafile
|
|
* @short_description: Image file operations (load, save, etc.)
|
|
*
|
|
* Image file operations (load, save, etc.)
|
|
**/
|
|
|
|
|
|
/**
|
|
* pika_file_load:
|
|
* @run_mode: The run mode.
|
|
* @file: The file to load.
|
|
*
|
|
* Loads an image file by invoking the right load handler.
|
|
*
|
|
* This procedure invokes the correct file load handler using magic if
|
|
* possible, and falling back on the file's extension and/or prefix if
|
|
* not.
|
|
*
|
|
* Returns: (transfer none): The output image.
|
|
**/
|
|
PikaImage *
|
|
pika_file_load (PikaRunMode run_mode,
|
|
GFile *file)
|
|
{
|
|
PikaValueArray *args;
|
|
PikaValueArray *return_vals;
|
|
PikaImage *image = NULL;
|
|
|
|
args = pika_value_array_new_from_types (NULL,
|
|
PIKA_TYPE_RUN_MODE, run_mode,
|
|
G_TYPE_FILE, file,
|
|
G_TYPE_NONE);
|
|
|
|
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
|
|
"pika-file-load",
|
|
args);
|
|
pika_value_array_unref (args);
|
|
|
|
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
|
|
image = PIKA_VALUES_GET_IMAGE (return_vals, 1);
|
|
|
|
pika_value_array_unref (return_vals);
|
|
|
|
return image;
|
|
}
|
|
|
|
/**
|
|
* pika_file_load_layer:
|
|
* @run_mode: The run mode.
|
|
* @image: Destination image.
|
|
* @file: The file to load.
|
|
*
|
|
* Loads an image file as a layer for an existing image.
|
|
*
|
|
* This procedure behaves like the file-load procedure but opens the
|
|
* specified image as a layer for an existing image. The returned layer
|
|
* needs to be added to the existing image with
|
|
* pika_image_insert_layer().
|
|
*
|
|
* Returns: (transfer none): The layer created when loading the image file.
|
|
*
|
|
* Since: 2.4
|
|
**/
|
|
PikaLayer *
|
|
pika_file_load_layer (PikaRunMode run_mode,
|
|
PikaImage *image,
|
|
GFile *file)
|
|
{
|
|
PikaValueArray *args;
|
|
PikaValueArray *return_vals;
|
|
PikaLayer *layer = NULL;
|
|
|
|
args = pika_value_array_new_from_types (NULL,
|
|
PIKA_TYPE_RUN_MODE, run_mode,
|
|
PIKA_TYPE_IMAGE, image,
|
|
G_TYPE_FILE, file,
|
|
G_TYPE_NONE);
|
|
|
|
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
|
|
"pika-file-load-layer",
|
|
args);
|
|
pika_value_array_unref (args);
|
|
|
|
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
|
|
layer = PIKA_VALUES_GET_LAYER (return_vals, 1);
|
|
|
|
pika_value_array_unref (return_vals);
|
|
|
|
return layer;
|
|
}
|
|
|
|
/**
|
|
* pika_file_load_layers:
|
|
* @run_mode: The run mode.
|
|
* @image: Destination image.
|
|
* @file: The file to load.
|
|
* @num_layers: (out): The number of loaded layers.
|
|
*
|
|
* Loads an image file as layers for an existing image.
|
|
*
|
|
* This procedure behaves like the file-load procedure but opens the
|
|
* specified image as layers for an existing image. The returned layers
|
|
* needs to be added to the existing image with
|
|
* pika_image_insert_layer().
|
|
*
|
|
* Returns: (array length=num_layers) (element-type PikaLayer) (transfer container):
|
|
* The list of loaded layers.
|
|
* The returned value must be freed with g_free().
|
|
*
|
|
* Since: 2.4
|
|
**/
|
|
PikaLayer **
|
|
pika_file_load_layers (PikaRunMode run_mode,
|
|
PikaImage *image,
|
|
GFile *file,
|
|
gint *num_layers)
|
|
{
|
|
PikaValueArray *args;
|
|
PikaValueArray *return_vals;
|
|
PikaLayer **layers = NULL;
|
|
|
|
args = pika_value_array_new_from_types (NULL,
|
|
PIKA_TYPE_RUN_MODE, run_mode,
|
|
PIKA_TYPE_IMAGE, image,
|
|
G_TYPE_FILE, file,
|
|
G_TYPE_NONE);
|
|
|
|
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
|
|
"pika-file-load-layers",
|
|
args);
|
|
pika_value_array_unref (args);
|
|
|
|
*num_layers = 0;
|
|
|
|
if (PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS)
|
|
{
|
|
*num_layers = PIKA_VALUES_GET_INT (return_vals, 1);
|
|
{ PikaObjectArray *a = g_value_get_boxed (pika_value_array_index (return_vals, 2)); if (a) layers = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
|
}
|
|
|
|
pika_value_array_unref (return_vals);
|
|
|
|
return layers;
|
|
}
|
|
|
|
/**
|
|
* pika_file_save:
|
|
* @run_mode: The run mode.
|
|
* @image: Input image.
|
|
* @num_drawables: The number of drawables to save.
|
|
* @drawables: (array length=num_drawables) (element-type PikaItem): Drawables to save.
|
|
* @file: The file to save the image in.
|
|
*
|
|
* Saves a file by extension.
|
|
*
|
|
* This procedure invokes the correct file save handler according to
|
|
* the file's extension and/or prefix.
|
|
*
|
|
* Returns: TRUE on success.
|
|
**/
|
|
gboolean
|
|
pika_file_save (PikaRunMode run_mode,
|
|
PikaImage *image,
|
|
gint num_drawables,
|
|
const PikaItem **drawables,
|
|
GFile *file)
|
|
{
|
|
PikaValueArray *args;
|
|
PikaValueArray *return_vals;
|
|
gboolean success = TRUE;
|
|
|
|
args = pika_value_array_new_from_types (NULL,
|
|
PIKA_TYPE_RUN_MODE, run_mode,
|
|
PIKA_TYPE_IMAGE, image,
|
|
G_TYPE_INT, num_drawables,
|
|
PIKA_TYPE_OBJECT_ARRAY, NULL,
|
|
G_TYPE_FILE, file,
|
|
G_TYPE_NONE);
|
|
pika_value_set_object_array (pika_value_array_index (args, 3), PIKA_TYPE_ITEM, (GObject **) drawables, num_drawables);
|
|
|
|
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
|
|
"pika-file-save",
|
|
args);
|
|
pika_value_array_unref (args);
|
|
|
|
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
|
|
|
|
pika_value_array_unref (return_vals);
|
|
|
|
return success;
|
|
}
|
|
|
|
/**
|
|
* pika_file_save_thumbnail:
|
|
* @image: The image.
|
|
* @file: The file the thumbnail belongs to.
|
|
*
|
|
* Saves a thumbnail for the given image
|
|
*
|
|
* This procedure saves a thumbnail for the given image according to
|
|
* the Free Desktop Thumbnail Managing Standard. The thumbnail is saved
|
|
* so that it belongs to the given file. This means you have to save
|
|
* the image under this name first, otherwise this procedure will fail.
|
|
* This procedure may become useful if you want to explicitly save a
|
|
* thumbnail with a file.
|
|
*
|
|
* Returns: TRUE on success.
|
|
**/
|
|
gboolean
|
|
pika_file_save_thumbnail (PikaImage *image,
|
|
GFile *file)
|
|
{
|
|
PikaValueArray *args;
|
|
PikaValueArray *return_vals;
|
|
gboolean success = TRUE;
|
|
|
|
args = pika_value_array_new_from_types (NULL,
|
|
PIKA_TYPE_IMAGE, image,
|
|
G_TYPE_FILE, file,
|
|
G_TYPE_NONE);
|
|
|
|
return_vals = pika_pdb_run_procedure_array (pika_get_pdb (),
|
|
"pika-file-save-thumbnail",
|
|
args);
|
|
pika_value_array_unref (args);
|
|
|
|
success = PIKA_VALUES_GET_ENUM (return_vals, 0) == PIKA_PDB_SUCCESS;
|
|
|
|
pika_value_array_unref (return_vals);
|
|
|
|
return success;
|
|
}
|