mirror of https://github.com/GNOME/gimp.git
parent
bc0c4de548
commit
5135d61119
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Tue Dec 14 20:37:44 CET 1999 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/Makefile.am
|
||||
* app/fileops.c
|
||||
* app/fileops.h
|
||||
* app/fileopsP.h: new file
|
||||
* app/fileops_cmds.c
|
||||
* app/internal_procs.c:
|
||||
* tools/pdbgen/pdb/fileops.pdb
|
||||
Added new PDB interfaces file_[load|save]_thumbnail. Wolfgang will
|
||||
need this for the new GAP interface, so better implement them now.
|
||||
|
||||
* plug-ins/common/screenshot.c: try to be more sane when xwd fails
|
||||
to load the temporary file
|
||||
|
||||
Tue Dec 14 15:10:16 CET 1999 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/blend.c
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "gimpcontext.h"
|
||||
#include "gimpui.h"
|
||||
#include "fileops.h"
|
||||
#include "fileopsP.h"
|
||||
#include "menus.h"
|
||||
#include "layer.h"
|
||||
#include "channel.h"
|
||||
|
@ -729,7 +730,7 @@ file_open (char *filename,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static TempBuf *
|
||||
TempBuf *
|
||||
make_thumb_tempbuf (GimpImage* gimage)
|
||||
{
|
||||
gint w,h;
|
||||
|
@ -835,8 +836,8 @@ make_RGBbuf_from_tempbuf (TempBuf *tempbuf,
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
file_save_thumbnail (GimpImage * gimage,
|
||||
gboolean
|
||||
file_save_thumbnail (GimpImage *gimage,
|
||||
const char *full_source_filename,
|
||||
TempBuf *tempbuf)
|
||||
{
|
||||
|
@ -1068,7 +1069,7 @@ file_save (GimpImage *gimage,
|
|||
|
||||
/* The readXVThumb function source may be re-used under
|
||||
the XFree86-style license. <adam@gimp.org> */
|
||||
static guchar*
|
||||
guchar*
|
||||
readXVThumb (const gchar *fnam,
|
||||
gint *w,
|
||||
gint *h,
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __FILE_IO_H__
|
||||
#define __FILE_IO_H__
|
||||
#ifndef __FILE_OPS_H__
|
||||
#define __FILE_OPS_H__
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -49,11 +49,10 @@ int file_save (GimpImage* gimage,
|
|||
char *filename,
|
||||
char *raw_filename,
|
||||
gint mode);
|
||||
|
||||
PlugInProcDef* file_proc_find (GSList *procs,
|
||||
char *filename);
|
||||
|
||||
extern GSList *load_procs;
|
||||
extern GSList *save_procs;
|
||||
|
||||
#endif /* FILE_IO_H */
|
||||
#endif /* FILE_OPS_H */
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __FILE_OPS_P_H__
|
||||
#define __FILE_OPS_P_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* functions that need only be accessed from file_ops_cmds.c */
|
||||
|
||||
TempBuf* make_thumb_tempbuf (GimpImage *gimage);
|
||||
guchar* readXVThumb (const gchar *fnam,
|
||||
gint *w,
|
||||
gint *h,
|
||||
gchar **imginfo /* caller frees if != NULL */);
|
||||
gboolean file_save_thumbnail (GimpImage *gimage,
|
||||
const char *full_source_filename,
|
||||
TempBuf *tempbuf);
|
||||
|
||||
#endif /* FILE_OPS_P_H */
|
|
@ -29,6 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include "fileops.h"
|
||||
#include "fileopsP.h"
|
||||
#include "gimprc.h"
|
||||
#include "plug_in.h"
|
||||
|
||||
|
@ -36,6 +37,8 @@
|
|||
|
||||
static ProcRecord file_load_proc;
|
||||
static ProcRecord file_save_proc;
|
||||
static ProcRecord file_load_thumbnail_proc;
|
||||
static ProcRecord file_save_thumbnail_proc;
|
||||
static ProcRecord temp_name_proc;
|
||||
static ProcRecord register_magic_load_handler_proc;
|
||||
static ProcRecord register_load_handler_proc;
|
||||
|
@ -46,6 +49,8 @@ register_fileops_procs (void)
|
|||
{
|
||||
procedural_db_register (&file_load_proc);
|
||||
procedural_db_register (&file_save_proc);
|
||||
procedural_db_register (&file_load_thumbnail_proc);
|
||||
procedural_db_register (&file_save_thumbnail_proc);
|
||||
procedural_db_register (&temp_name_proc);
|
||||
procedural_db_register (®ister_magic_load_handler_proc);
|
||||
procedural_db_register (®ister_load_handler_proc);
|
||||
|
@ -188,6 +193,166 @@ static ProcRecord file_save_proc =
|
|||
{ { file_save_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
file_load_thumbnail_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *filename;
|
||||
gint32 width = 0;
|
||||
gint32 height = 0;
|
||||
guint8 *thumb_data = NULL;
|
||||
gchar *pname;
|
||||
gchar *fname;
|
||||
gchar *tname;
|
||||
guchar *raw_thumb;
|
||||
gchar *imginfo = NULL;
|
||||
gint i;
|
||||
|
||||
filename = (gchar *) args[0].value.pdb_pointer;
|
||||
if (filename == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
pname = g_dirname (filename);
|
||||
fname = g_basename (filename);
|
||||
tname = g_strconcat (pname, G_DIR_SEPARATOR_S, ".xvpics", G_DIR_SEPARATOR_S,
|
||||
fname,
|
||||
NULL);
|
||||
g_free (pname);
|
||||
raw_thumb = readXVThumb (tname, &width, &height, &imginfo);
|
||||
g_free (tname);
|
||||
|
||||
if (raw_thumb)
|
||||
{
|
||||
thumb_data = g_malloc (3 * width * height);
|
||||
|
||||
for (i=0; i<width*height; i++)
|
||||
{
|
||||
thumb_data[i*3 ] = ((raw_thumb[i]>>5)*255)/7;
|
||||
thumb_data[i*3+1] = (((raw_thumb[i]>>2)&7)*255)/7;
|
||||
thumb_data[i*3+2] = (((raw_thumb[i])&3)*255)/3;
|
||||
}
|
||||
g_free (raw_thumb);
|
||||
success = TRUE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&file_load_thumbnail_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = width;
|
||||
return_args[2].value.pdb_int = height;
|
||||
return_args[3].value.pdb_pointer = thumb_data;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg file_load_thumbnail_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"filename",
|
||||
"The name of the file that owns the thumbnail to load"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg file_load_thumbnail_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The width of the thumbnail"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"height",
|
||||
"The height of the thumbnail"
|
||||
},
|
||||
{
|
||||
PDB_INT8ARRAY,
|
||||
"thumb_data",
|
||||
"The thumbnail data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord file_load_thumbnail_proc =
|
||||
{
|
||||
"gimp_file_load_thumbnail",
|
||||
"Loads the thumbnail for a file.",
|
||||
"This procedure tries to load a thumbnail that belongs to the file with the given filename. This name is a full pathname. The returned data is an array of colordepth 3 (RGB), regardless of the image type. Width and height of the thumbnail are also returned. Don't use this function if you need a thumbnail of an already opened image, use gimp_image_thumbnail instead.",
|
||||
"Adam D. Moss, Sven Neumann",
|
||||
"Adam D. Moss, Sven Neumann",
|
||||
"1999",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
file_load_thumbnail_inargs,
|
||||
3,
|
||||
file_load_thumbnail_outargs,
|
||||
{ { file_load_thumbnail_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
file_save_thumbnail_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *gimage;
|
||||
gchar *filename;
|
||||
TempBuf *thumb;
|
||||
|
||||
gimage = pdb_id_to_image (args[0].value.pdb_int);
|
||||
if (gimage == NULL)
|
||||
success = FALSE;
|
||||
|
||||
filename = (gchar *) args[1].value.pdb_pointer;
|
||||
if (filename == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
thumb = make_thumb_tempbuf (gimage);
|
||||
if (file_save_thumbnail (gimage, filename, thumb))
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&file_save_thumbnail_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg file_save_thumbnail_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_IMAGE,
|
||||
"image",
|
||||
"The image"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"filename",
|
||||
"The name of the file the thumbnail belongs to"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord file_save_thumbnail_proc =
|
||||
{
|
||||
"gimp_file_save_thumbnail",
|
||||
"Saves a thumbnail for the given image",
|
||||
"This procedure saves a thumbnail in the .xvpics format for the given image. The thumbnail is saved so that it belongs to the file with the given filename. 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 explicitely save a thumbnail with a file.",
|
||||
"Josh MacDonald",
|
||||
"Josh MacDonald",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
file_save_thumbnail_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { file_save_thumbnail_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
temp_name_invoker (Argument *args)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* ScreenShot plug-in v0.9.2
|
||||
* ScreenShot plug-in v0.9.3
|
||||
* Sven Neumann, neumanns@uni-duesseldorf.de
|
||||
* 1999/09/01
|
||||
*
|
||||
|
@ -43,6 +43,7 @@
|
|||
* (99/08/12) v0.9.1 somebody changed the dialog;
|
||||
* unset the image name and set the resolution
|
||||
* (99/09/01) v0.9.2 tried to fix a bug
|
||||
* (99/12/14) v0.9.3 another try
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -153,7 +154,7 @@ static void query (void)
|
|||
"a parameter."),
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"1998, 1999",
|
||||
"v0.9.2 (99/09/01)",
|
||||
"v0.9.3 (99/12/14)",
|
||||
N_("<Toolbox>/File/Acquire/Screen Shot..."),
|
||||
NULL,
|
||||
PROC_EXTENSION,
|
||||
|
@ -331,34 +332,40 @@ shoot (void)
|
|||
PARAM_STRING, tmpname,
|
||||
PARAM_STRING, tmpname,
|
||||
PARAM_END);
|
||||
image_ID = params[1].data.d_image;
|
||||
if (params[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
image_ID = params[1].data.d_image;
|
||||
}
|
||||
gimp_destroy_params (params, retvals);
|
||||
|
||||
|
||||
/* get rid of the tmpfile */
|
||||
unlink (tmpname);
|
||||
g_free (tmpname);
|
||||
|
||||
/* figure out the monitor resolution and set the image to it */
|
||||
params = gimp_run_procedure ("gimp_get_monitor_resolution",
|
||||
&retvals,
|
||||
PARAM_END);
|
||||
if (params[0].data.d_status == STATUS_SUCCESS)
|
||||
if (image_ID != -1)
|
||||
{
|
||||
xres = params[1].data.d_float;
|
||||
yres = params[2].data.d_float;
|
||||
/* figure out the monitor resolution and set the image to it */
|
||||
params = gimp_run_procedure ("gimp_get_monitor_resolution",
|
||||
&retvals,
|
||||
PARAM_END);
|
||||
if (params[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
xres = params[1].data.d_float;
|
||||
yres = params[2].data.d_float;
|
||||
}
|
||||
else
|
||||
{
|
||||
xres = 72.0;
|
||||
yres = 72.0;
|
||||
}
|
||||
gimp_destroy_params (params, retvals);
|
||||
|
||||
gimp_image_set_resolution (image_ID, xres, yres);
|
||||
|
||||
/* unset the image filename */
|
||||
gimp_image_set_filename (image_ID, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
xres = 72.0;
|
||||
yres = 72.0;
|
||||
}
|
||||
gimp_destroy_params (params, retvals);
|
||||
|
||||
gimp_image_set_resolution (image_ID, xres, yres);
|
||||
|
||||
/* unset the image filename */
|
||||
gimp_image_set_filename (image_ID, "");
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,6 +154,102 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub file_load_thumbnail {
|
||||
$blurb = 'Loads the thumbnail for a file.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure tries to load a thumbnail that belongs to the file with
|
||||
the given filename. This name is a full pathname. The returned data is
|
||||
an array of colordepth 3 (RGB), regardless of the image type. Width and
|
||||
height of the thumbnail are also returned. Don't use this function if
|
||||
you need a thumbnail of an already opened image, use gimp_image_thumbnail
|
||||
instead.
|
||||
HELP
|
||||
|
||||
$author = $copyright = 'Adam D. Moss, Sven Neumann';
|
||||
$date = '1999';
|
||||
|
||||
@inargs = (
|
||||
{ name => 'filename', type => 'string',
|
||||
desc => 'The name of the file that owns the thumbnail to load' },
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'width', type => 'int32', init => 1,
|
||||
desc => 'The width of the thumbnail' },
|
||||
{ name => 'height', type => 'int32', init => 1,
|
||||
desc => 'The height of the thumbnail' },
|
||||
{ name => 'thumb_data', type => 'int8array', init => 1,
|
||||
desc => 'The thumbnail data'},
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("fileopsP.h") ],
|
||||
vars => [ 'gchar *pname', 'gchar *fname', 'gchar *tname',
|
||||
'guchar *raw_thumb', 'gchar *imginfo = NULL', 'gint i' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
pname = g_dirname (filename);
|
||||
fname = g_basename (filename);
|
||||
tname = g_strconcat (pname, G_DIR_SEPARATOR_S, ".xvpics", G_DIR_SEPARATOR_S,
|
||||
fname,
|
||||
NULL);
|
||||
g_free (pname);
|
||||
raw_thumb = readXVThumb (tname, &width, &height, &imginfo);
|
||||
g_free (tname);
|
||||
|
||||
if (raw_thumb)
|
||||
{
|
||||
thumb_data = g_malloc (3 * width * height);
|
||||
|
||||
for (i=0; i<width*height; i++)
|
||||
{
|
||||
thumb_data[i*3 ] = ((raw_thumb[i]>>5)*255)/7;
|
||||
thumb_data[i*3+1] = (((raw_thumb[i]>>2)&7)*255)/7;
|
||||
thumb_data[i*3+2] = (((raw_thumb[i])&3)*255)/3;
|
||||
}
|
||||
g_free (raw_thumb);
|
||||
success = TRUE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub file_save_thumbnail {
|
||||
$blurb = 'Saves a thumbnail for the given image';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure saves a thumbnail in the .xvpics format for the given image.
|
||||
The thumbnail is saved so that it belongs to the file with the given
|
||||
filename. 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 explicitely save a thumbnail with a file.
|
||||
HELP
|
||||
|
||||
&pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&std_image_arg,
|
||||
{ name => 'filename', type => 'string',
|
||||
desc => 'The name of the file the thumbnail belongs to' },
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("fileopsP.h") ],
|
||||
vars => [ 'TempBuf *thumb' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
thumb = make_thumb_tempbuf (gimage);
|
||||
if (file_save_thumbnail (gimage, filename, thumb))
|
||||
success = TRUE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub temp_name {
|
||||
$blurb = 'Generates a unique filename.';
|
||||
|
||||
|
@ -313,8 +409,8 @@ CODE
|
|||
@headers = qw("fileops.h" "plug_in.h" "config.h" "libgimp/gimpintl.h"
|
||||
<unistd.h>);
|
||||
|
||||
@procs = qw(file_load file_save temp_name register_magic_load_handler
|
||||
register_load_handler register_save_handler);
|
||||
@procs = qw(file_load file_save file_load_thumbnail file_save_thumbnail temp_name
|
||||
register_magic_load_handler register_load_handler register_save_handler);
|
||||
%exports = (app => [@procs]);
|
||||
|
||||
$desc = 'File Operations';
|
||||
|
|
Loading…
Reference in New Issue