Import newer upstream.
This commit is contained in:
@ -1031,7 +1031,7 @@ get_file_info (GFile *file)
|
||||
|
||||
if (info)
|
||||
{
|
||||
size = g_file_info_get_size (info);
|
||||
size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ get_file_size (GFile *file,
|
||||
NULL, error);
|
||||
if (info)
|
||||
{
|
||||
size = g_file_info_get_size (info);
|
||||
size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ static PikaValueArray * pix_save (PikaProcedure *procedure,
|
||||
|
||||
static PikaImage * load_image (GFile *file,
|
||||
GError **error);
|
||||
static PikaImage * load_esm_image (GInputStream *input,
|
||||
GError **error);
|
||||
static gboolean save_image (GFile *file,
|
||||
PikaImage *image,
|
||||
PikaDrawable *drawable,
|
||||
@ -174,9 +176,9 @@ pix_create_procedure (PikaPlugIn *plug_in,
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
"Loads files of the Alias|Wavefront "
|
||||
"Pix file format",
|
||||
"or Esm Software Pix file format",
|
||||
"Loads files of the Alias|Wavefront "
|
||||
"Pix file format",
|
||||
"or Esm Software Pix file format",
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Michael Taylor",
|
||||
@ -185,6 +187,10 @@ pix_create_procedure (PikaPlugIn *plug_in,
|
||||
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
"pix,matte,mask,alpha,als");
|
||||
/* Magic Number for Esm Software PIX files */
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
"0,string,Esm Software PIX file");
|
||||
|
||||
}
|
||||
else if (! strcmp (name, SAVE_PROC))
|
||||
{
|
||||
@ -375,7 +381,7 @@ load_image (GFile *file,
|
||||
PikaImageType gdtype;
|
||||
guchar *dest;
|
||||
guchar *dest_base;
|
||||
PikaImage *image;
|
||||
PikaImage *image = NULL;
|
||||
PikaLayer *layer;
|
||||
gushort width, height, depth;
|
||||
gint i, j, tile_height, row;
|
||||
@ -417,6 +423,28 @@ load_image (GFile *file,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if this is Esm Software PIX file format */
|
||||
gchar esm_header[22];
|
||||
gsize bytes_read;
|
||||
|
||||
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_SET, NULL, NULL);
|
||||
if (g_input_stream_read_all (input, &esm_header, sizeof (esm_header),
|
||||
&bytes_read, NULL, NULL))
|
||||
{
|
||||
esm_header[21] = '\0';
|
||||
|
||||
if (g_str_has_prefix (esm_header, "Esm Software PIX file"))
|
||||
image = load_esm_image (input, error);
|
||||
|
||||
if (image)
|
||||
{
|
||||
g_object_unref (input);
|
||||
pika_progress_update (1.0);
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
/* Header is invalid */
|
||||
g_object_unref (input);
|
||||
return NULL;
|
||||
@ -534,6 +562,73 @@ load_image (GFile *file,
|
||||
return image;
|
||||
}
|
||||
|
||||
static PikaImage *
|
||||
load_esm_image (GInputStream *input,
|
||||
GError **error)
|
||||
{
|
||||
PikaImage *image = NULL;
|
||||
PikaValueArray *return_vals = NULL;
|
||||
GFile *temp_file = NULL;
|
||||
FILE *fp;
|
||||
goffset file_size;
|
||||
|
||||
g_seekable_seek (G_SEEKABLE (input), 0, G_SEEK_END, NULL, error);
|
||||
file_size = g_seekable_tell (G_SEEKABLE (input));
|
||||
g_seekable_seek (G_SEEKABLE (input), 21, G_SEEK_SET, NULL, error);
|
||||
|
||||
/* Esm Software PIX format is just a JPEG with an extra 21 byte header */
|
||||
temp_file = pika_temp_file ("jpeg");
|
||||
fp = g_fopen (g_file_peek_path (temp_file), "wb");
|
||||
|
||||
if (! fp)
|
||||
{
|
||||
g_file_delete (temp_file, NULL, NULL);
|
||||
g_object_unref (temp_file);
|
||||
|
||||
g_message (_("Error trying to open temporary JPEG file '%s' "
|
||||
"for Esm Software pix loading: %s"),
|
||||
pika_file_get_utf8_name (temp_file),
|
||||
g_strerror (errno));
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
guchar buffer[file_size - 21];
|
||||
|
||||
if (! g_input_stream_read_all (input, buffer, sizeof (buffer),
|
||||
NULL, NULL, error))
|
||||
{
|
||||
g_file_delete (temp_file, NULL, NULL);
|
||||
g_object_unref (temp_file);
|
||||
|
||||
g_printerr (_("Invalid Esm Software PIX file"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fwrite (buffer, sizeof (guchar), file_size, fp);
|
||||
fclose (fp);
|
||||
|
||||
return_vals =
|
||||
pika_pdb_run_procedure (pika_get_pdb (),
|
||||
"file-jpeg-load",
|
||||
PIKA_TYPE_RUN_MODE, PIKA_RUN_NONINTERACTIVE,
|
||||
G_TYPE_FILE, temp_file,
|
||||
G_TYPE_NONE);
|
||||
|
||||
if (return_vals)
|
||||
{
|
||||
image = g_value_get_object (pika_value_array_index (return_vals, 1));
|
||||
|
||||
pika_value_array_unref (return_vals);
|
||||
}
|
||||
|
||||
g_file_delete (temp_file, NULL, NULL);
|
||||
g_object_unref (temp_file);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* save the given file out as an alias pix or matte file
|
||||
|
@ -1279,8 +1279,17 @@ read_color_block (FILE *f,
|
||||
}
|
||||
|
||||
color_palette_entries = GUINT32_FROM_LE (entry_count);
|
||||
/* TODO: PIKA currently only supports a maximum of 256 colors
|
||||
* in an indexed image. If this changes, we can change this check */
|
||||
if (color_palette_entries > 256)
|
||||
{
|
||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Error: Unsupported palette size"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* psp color palette entries are stored as RGBA so 4 bytes per entry
|
||||
where the fourth bytes is always zero */
|
||||
* where the fourth bytes is always zero */
|
||||
pal_size = color_palette_entries * 4;
|
||||
color_palette = g_malloc (pal_size);
|
||||
if (fread (color_palette, pal_size, 1, f) < 1)
|
||||
@ -1649,7 +1658,7 @@ read_channel_data (FILE *f,
|
||||
else
|
||||
endq = q + line_width * height;
|
||||
|
||||
buf = g_malloc (127);
|
||||
buf = g_malloc (128);
|
||||
while (q < endq)
|
||||
{
|
||||
fread (&runcount, 1, 1, f);
|
||||
|
@ -706,7 +706,7 @@ get_file_info (GFile *file)
|
||||
|
||||
if (info)
|
||||
{
|
||||
size = g_file_info_get_size (info);
|
||||
size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ send_image (GObject *config,
|
||||
while ((info = g_file_enumerator_next_file (enumerator,
|
||||
NULL, NULL)))
|
||||
{
|
||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_REGULAR)
|
||||
if (g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_REGULAR)
|
||||
{
|
||||
GFile *file = g_file_enumerator_get_child (enumerator, info);
|
||||
g_file_delete (file, NULL, NULL);
|
||||
|
@ -136,7 +136,7 @@ background_jpeg_save (PreviewPersistent *pp)
|
||||
|
||||
if (info)
|
||||
{
|
||||
goffset size = g_file_info_get_size (info);
|
||||
goffset size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
gchar *size_text;
|
||||
|
||||
size_text = g_format_size (size);
|
||||
|
@ -571,7 +571,7 @@ tiff_io_get_file_size (thandle_t handle)
|
||||
}
|
||||
else
|
||||
{
|
||||
size = g_file_info_get_size (info);
|
||||
size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
||||
|
@ -1110,10 +1110,10 @@ fractalexplorer_list_load_all (const gchar *explorer_path)
|
||||
|
||||
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)))
|
||||
{
|
||||
GFileType file_type = g_file_info_get_file_type (info);
|
||||
GFileType file_type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
|
||||
|
||||
if (file_type == G_FILE_TYPE_REGULAR &&
|
||||
! g_file_info_get_is_hidden (info))
|
||||
! g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
|
||||
{
|
||||
fractalexplorerOBJ *fractalexplorer;
|
||||
GFile *child;
|
||||
|
@ -1776,10 +1776,10 @@ gflares_list_load_all (void)
|
||||
|
||||
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)))
|
||||
{
|
||||
GFileType file_type = g_file_info_get_file_type (info);
|
||||
GFileType file_type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
|
||||
|
||||
if (file_type == G_FILE_TYPE_REGULAR &&
|
||||
! g_file_info_get_is_hidden (info))
|
||||
! g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
|
||||
{
|
||||
GFlare *gflare;
|
||||
GFile *child;
|
||||
|
@ -262,7 +262,7 @@ pika_help_locale_parse (PikaHelpLocale *locale,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
size = g_file_info_get_size (info);
|
||||
size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
|
||||
|
||||
g_object_unref (info);
|
||||
}
|
||||
|
@ -320,11 +320,11 @@ script_fu_load_directory (GFile *directory)
|
||||
|
||||
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)))
|
||||
{
|
||||
GFileType file_type = g_file_info_get_file_type (info);
|
||||
GFileType file_type = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
|
||||
|
||||
if ((file_type == G_FILE_TYPE_REGULAR ||
|
||||
file_type == G_FILE_TYPE_DIRECTORY) &&
|
||||
! g_file_info_get_is_hidden (info))
|
||||
! g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN))
|
||||
{
|
||||
GFile *child = g_file_enumerator_get_child (enumerator, info);
|
||||
|
||||
|
Reference in New Issue
Block a user