mirror of https://github.com/GNOME/gimp.git
applied gimp-bjj-980922-0, makes get_token's EOF report "sticky"
* app/general.c: applied gimp-bjj-980922-0, makes get_token's EOF report "sticky" * app/devices.c: applied gimp-bjj-980922-1, sanity check our saved device info for NULL pointers * app/file_new_dialog.c * app/gimage_cmds.[ch] * app/gimpimage.[ch] * app/info_window.c * app/internal_procs.c * libgimp/gimp.h * libgimp/gimpimage.c * plug-ins/tiff/tiff.c: applied gimp-austin-980916-0, adds resolution info to GimpImage, with accessors, and support in the tiff plug-in -Yosh
This commit is contained in:
parent
8357369ba3
commit
65ab53a840
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
Mon Oct 5 02:42:47 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/general.c: applied gimp-bjj-980922-0, makes get_token's
|
||||
EOF report "sticky"
|
||||
|
||||
* app/devices.c: applied gimp-bjj-980922-1, sanity check our
|
||||
saved device info for NULL pointers
|
||||
|
||||
* app/file_new_dialog.c
|
||||
* app/gimage_cmds.[ch]
|
||||
* app/gimpimage.[ch]
|
||||
* app/info_window.c
|
||||
* app/internal_procs.c
|
||||
* libgimp/gimp.h
|
||||
* libgimp/gimpimage.c
|
||||
* plug-ins/tiff/tiff.c: applied gimp-austin-980916-0, adds resolution
|
||||
info to GimpImage, with accessors, and support in the tiff plug-in
|
||||
|
||||
Mon Oct 5 00:28:58 PDT 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* po/de.po
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -597,9 +597,12 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
|
||||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
if (device_info->brush)
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
if (device_info->pattern)
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
if (device_info->tool)
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
device_info->foreground[0],
|
||||
|
|
|
@ -113,6 +113,8 @@ file_new_ok_callback (GtkWidget *widget,
|
|||
|
||||
gimage = gimage_new (vals->width, vals->height, vals->type);
|
||||
|
||||
gimp_image_set_resolution(gimage, vals->resolution);
|
||||
|
||||
/* Make the background (or first) layer */
|
||||
layer = layer_new (gimage, gimage->width, gimage->height,
|
||||
type, "Background", OPAQUE_OPACITY, NORMAL);
|
||||
|
|
|
@ -39,6 +39,7 @@ struct _InfoWinData
|
|||
char visual_class_str[MAX_BUF];
|
||||
char visual_depth_str[MAX_BUF];
|
||||
char shades_str[MAX_BUF];
|
||||
char resolution_str[MAX_BUF];
|
||||
};
|
||||
|
||||
/* The different classes of visuals */
|
||||
|
@ -144,6 +145,7 @@ info_window_create (void *gdisp_ptr)
|
|||
iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData));
|
||||
info_win->user_data = iwd;
|
||||
iwd->dimensions_str[0] = '\0';
|
||||
iwd->resolution_str[0] = '\0';
|
||||
iwd->scale_str[0] = '\0';
|
||||
iwd->color_type_str[0] = '\0';
|
||||
iwd->visual_class_str[0] = '\0';
|
||||
|
@ -152,6 +154,7 @@ info_window_create (void *gdisp_ptr)
|
|||
|
||||
/* add the information fields */
|
||||
info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Resolution: ", iwd->resolution_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL);
|
||||
|
@ -195,6 +198,9 @@ info_window_update (InfoDialog *info_win,
|
|||
sprintf (iwd->dimensions_str, "%d x %d",
|
||||
(int) gdisp->gimage->width, (int) gdisp->gimage->height);
|
||||
|
||||
/* image resolution */
|
||||
sprintf (iwd->resolution_str, "%g dpi", gdisp->gimage->resolution);
|
||||
|
||||
/* zoom ratio */
|
||||
sprintf (iwd->scale_str, "%d:%d",
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
|
|
|
@ -113,6 +113,8 @@ file_new_ok_callback (GtkWidget *widget,
|
|||
|
||||
gimage = gimage_new (vals->width, vals->height, vals->type);
|
||||
|
||||
gimp_image_set_resolution(gimage, vals->resolution);
|
||||
|
||||
/* Make the background (or first) layer */
|
||||
layer = layer_new (gimage, gimage->width, gimage->height,
|
||||
type, "Background", OPAQUE_OPACITY, NORMAL);
|
||||
|
|
|
@ -137,11 +137,11 @@ get_token (ParseInfo *info)
|
|||
info->position = -1;
|
||||
if ((info->position == -1) || (buffer[info->position] == '\0'))
|
||||
{
|
||||
info->position = 0;
|
||||
count = fread (buffer, sizeof (char), info->buffer_size - 1, info->fp);
|
||||
if ((count == 0) && feof (info->fp))
|
||||
return TOKEN_EOF;
|
||||
buffer[count] = '\0';
|
||||
info->position = 0;
|
||||
}
|
||||
|
||||
info->inc_charnum = TRUE;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "drawable_pvt.h" /* ick ick. */
|
||||
|
||||
static int int_value;
|
||||
static float float_value;
|
||||
static int success;
|
||||
static Argument *return_args;
|
||||
|
||||
|
@ -2766,6 +2767,142 @@ ProcRecord gimage_set_filename_proc =
|
|||
};
|
||||
|
||||
|
||||
|
||||
/***************************/
|
||||
/* GIMAGE_GET_RESOLUTION */
|
||||
|
||||
static Argument *
|
||||
gimage_get_resolution_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
float resolution;
|
||||
Argument *return_args;
|
||||
|
||||
resolution = 0;
|
||||
|
||||
success = TRUE;
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if ((gimage = gimage_get_ID (int_value)))
|
||||
resolution = gimage->resolution;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args= procedural_db_return_args(&gimage_get_resolution_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_float = resolution;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gimage_get_resolution_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg gimage_get_resolution_out_args[] =
|
||||
{
|
||||
{ PDB_FLOAT,
|
||||
"resolution",
|
||||
"the image's resolution, in dots per inch"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimage_get_resolution_proc =
|
||||
{
|
||||
"gimp_image_get_resolution",
|
||||
"Return the resolution of the image",
|
||||
"This procedure returns the image's resolution, in dots per inch. This value is independent of any of the layers in this image. A return value of 0.0 means the image was invalid.",
|
||||
"Austin Donnelly",
|
||||
"Austin Donnelly",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
gimage_get_resolution_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
gimage_get_resolution_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimage_get_resolution_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/***************************/
|
||||
/* GIMAGE_SET_RESOLUTION */
|
||||
|
||||
static Argument *
|
||||
gimage_set_resolution_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
Argument *return_args;
|
||||
|
||||
success = TRUE;
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (!(gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
float_value = args[1].value.pdb_float;
|
||||
gimage->resolution = float_value;
|
||||
}
|
||||
|
||||
return_args= procedural_db_return_args(&gimage_set_resolution_proc, success);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gimage_set_resolution_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"resolution",
|
||||
"resolution in dots per inch"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimage_set_resolution_proc =
|
||||
{
|
||||
"gimp_image_set_resolution",
|
||||
"Sets the resolution of the image",
|
||||
"This procedure sets the image's resolution, in dots per inch. This value is independent of any of the layers in this image. No scaling or resizing is performed.",
|
||||
"Austin Donnelly",
|
||||
"Austin Donnelly",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
2,
|
||||
gimage_set_resolution_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimage_set_resolution_invoker } },
|
||||
};
|
||||
|
||||
|
||||
|
||||
/******************/
|
||||
/* GIMAGE_WIDTH */
|
||||
|
||||
|
|
|
@ -58,6 +58,8 @@ extern ProcRecord gimage_active_drawable_proc;
|
|||
extern ProcRecord gimage_base_type_proc;
|
||||
extern ProcRecord gimage_get_filename_proc;
|
||||
extern ProcRecord gimage_set_filename_proc;
|
||||
extern ProcRecord gimage_get_resolution_proc;
|
||||
extern ProcRecord gimage_set_resolution_proc;
|
||||
extern ProcRecord gimage_width_proc;
|
||||
extern ProcRecord gimage_height_proc;
|
||||
extern ProcRecord gimage_get_cmap_proc;
|
||||
|
|
|
@ -150,6 +150,7 @@ static void gimp_image_init (GimpImage *gimage)
|
|||
gimage->comp_preview_valid[1] = FALSE;
|
||||
gimage->comp_preview_valid[2] = FALSE;
|
||||
gimage->comp_preview = NULL;
|
||||
gimage->resolution = 72.0; /* maybe should be rc-supplied default? */
|
||||
}
|
||||
|
||||
GtkType gimp_image_get_type(void){
|
||||
|
@ -293,6 +294,20 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (GimpImage *gimage, float resolution)
|
||||
{
|
||||
gimage->resolution = resolution;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (GimpImage *gimage)
|
||||
{
|
||||
return gimage->resolution;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
|
||||
int offset_x, int offset_y)
|
||||
|
|
|
@ -102,6 +102,8 @@ GtkType gimp_image_get_type(void);
|
|||
|
||||
GimpImage * gimp_image_new (int, int, int);
|
||||
void gimp_image_set_filename (GimpImage *, char *);
|
||||
void gimp_image_set_resolution (GimpImage *, float);
|
||||
float gimp_image_get_resolution (GimpImage *);
|
||||
void gimp_image_resize (GimpImage *, int, int, int, int);
|
||||
void gimp_image_scale (GimpImage *, int, int);
|
||||
GimpImage * gimp_image_get_named (char *);
|
||||
|
|
|
@ -19,7 +19,8 @@ struct _GimpImage
|
|||
int has_filename; /* has a valid filename */
|
||||
|
||||
int width, height; /* width and height attributes */
|
||||
int base_type; /* base gimp_image type */
|
||||
float resolution; /* image res, in dpi */
|
||||
int base_type; /* base gimp_image type */
|
||||
|
||||
unsigned char * cmap; /* colormap--for indexed */
|
||||
int num_cols; /* number of cols--for indexed */
|
||||
|
|
|
@ -597,9 +597,12 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
|
||||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
if (device_info->brush)
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
if (device_info->pattern)
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
if (device_info->tool)
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
device_info->foreground[0],
|
||||
|
|
|
@ -113,6 +113,8 @@ file_new_ok_callback (GtkWidget *widget,
|
|||
|
||||
gimage = gimage_new (vals->width, vals->height, vals->type);
|
||||
|
||||
gimp_image_set_resolution(gimage, vals->resolution);
|
||||
|
||||
/* Make the background (or first) layer */
|
||||
layer = layer_new (gimage, gimage->width, gimage->height,
|
||||
type, "Background", OPAQUE_OPACITY, NORMAL);
|
||||
|
|
|
@ -39,6 +39,7 @@ struct _InfoWinData
|
|||
char visual_class_str[MAX_BUF];
|
||||
char visual_depth_str[MAX_BUF];
|
||||
char shades_str[MAX_BUF];
|
||||
char resolution_str[MAX_BUF];
|
||||
};
|
||||
|
||||
/* The different classes of visuals */
|
||||
|
@ -144,6 +145,7 @@ info_window_create (void *gdisp_ptr)
|
|||
iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData));
|
||||
info_win->user_data = iwd;
|
||||
iwd->dimensions_str[0] = '\0';
|
||||
iwd->resolution_str[0] = '\0';
|
||||
iwd->scale_str[0] = '\0';
|
||||
iwd->color_type_str[0] = '\0';
|
||||
iwd->visual_class_str[0] = '\0';
|
||||
|
@ -152,6 +154,7 @@ info_window_create (void *gdisp_ptr)
|
|||
|
||||
/* add the information fields */
|
||||
info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Resolution: ", iwd->resolution_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL);
|
||||
|
@ -195,6 +198,9 @@ info_window_update (InfoDialog *info_win,
|
|||
sprintf (iwd->dimensions_str, "%d x %d",
|
||||
(int) gdisp->gimage->width, (int) gdisp->gimage->height);
|
||||
|
||||
/* image resolution */
|
||||
sprintf (iwd->resolution_str, "%g dpi", gdisp->gimage->resolution);
|
||||
|
||||
/* zoom ratio */
|
||||
sprintf (iwd->scale_str, "%d:%d",
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
|
|
|
@ -597,9 +597,12 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
|
||||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
if (device_info->brush)
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
if (device_info->pattern)
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
if (device_info->tool)
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
device_info->foreground[0],
|
||||
|
|
|
@ -39,6 +39,7 @@ struct _InfoWinData
|
|||
char visual_class_str[MAX_BUF];
|
||||
char visual_depth_str[MAX_BUF];
|
||||
char shades_str[MAX_BUF];
|
||||
char resolution_str[MAX_BUF];
|
||||
};
|
||||
|
||||
/* The different classes of visuals */
|
||||
|
@ -144,6 +145,7 @@ info_window_create (void *gdisp_ptr)
|
|||
iwd = (InfoWinData *) g_malloc (sizeof (InfoWinData));
|
||||
info_win->user_data = iwd;
|
||||
iwd->dimensions_str[0] = '\0';
|
||||
iwd->resolution_str[0] = '\0';
|
||||
iwd->scale_str[0] = '\0';
|
||||
iwd->color_type_str[0] = '\0';
|
||||
iwd->visual_class_str[0] = '\0';
|
||||
|
@ -152,6 +154,7 @@ info_window_create (void *gdisp_ptr)
|
|||
|
||||
/* add the information fields */
|
||||
info_dialog_add_field (info_win, "Dimensions (w x h): ", iwd->dimensions_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Resolution: ", iwd->resolution_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Scale Ratio: ", iwd->scale_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Display Type: ", iwd->color_type_str, NULL, NULL);
|
||||
info_dialog_add_field (info_win, "Visual Class: ", iwd->visual_class_str, NULL, NULL);
|
||||
|
@ -195,6 +198,9 @@ info_window_update (InfoDialog *info_win,
|
|||
sprintf (iwd->dimensions_str, "%d x %d",
|
||||
(int) gdisp->gimage->width, (int) gdisp->gimage->height);
|
||||
|
||||
/* image resolution */
|
||||
sprintf (iwd->resolution_str, "%g dpi", gdisp->gimage->resolution);
|
||||
|
||||
/* zoom ratio */
|
||||
sprintf (iwd->scale_str, "%d:%d",
|
||||
SCALEDEST (gdisp), SCALESRC (gdisp));
|
||||
|
|
|
@ -79,7 +79,7 @@ internal_procs_init ()
|
|||
{
|
||||
gfloat pcount = 0;
|
||||
/* grep -c procedural_db_register internal_procs.c */
|
||||
gfloat total_pcount = 217;
|
||||
gfloat total_pcount = 219;
|
||||
app_init_update_status("Internal Procedures", "Tool procedures",
|
||||
pcount/total_pcount);
|
||||
|
||||
|
@ -172,6 +172,8 @@ internal_procs_init ()
|
|||
procedural_db_register (&gimage_base_type_proc); pcount++;
|
||||
procedural_db_register (&gimage_get_filename_proc); pcount++;
|
||||
procedural_db_register (&gimage_set_filename_proc); pcount++;
|
||||
procedural_db_register (&gimage_get_resolution_proc); pcount++;
|
||||
procedural_db_register (&gimage_set_resolution_proc); pcount++;
|
||||
procedural_db_register (&gimage_width_proc); pcount++;
|
||||
procedural_db_register (&gimage_height_proc); pcount++;
|
||||
procedural_db_register (&gimage_get_cmap_proc); pcount++;
|
||||
|
|
|
@ -597,9 +597,12 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
|
||||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
if (device_info->brush)
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
if (device_info->pattern)
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
if (device_info->tool)
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
device_info->foreground[0],
|
||||
|
|
|
@ -597,9 +597,12 @@ devices_write_rc_device (DeviceInfo *device_info, FILE *fp)
|
|||
|
||||
if (device_info->is_init)
|
||||
{
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
if (device_info->brush)
|
||||
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
||||
if (device_info->pattern)
|
||||
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
||||
if (device_info->tool)
|
||||
fprintf(fp, "\n (tool \"%s\")",
|
||||
tool_info[device_info->tool].tool_name);
|
||||
fprintf(fp, "\n (foreground %d %d %d)",
|
||||
device_info->foreground[0],
|
||||
|
|
|
@ -425,6 +425,10 @@ void gimp_image_set_component_visible (gint32 image_ID,
|
|||
gint visible);
|
||||
void gimp_image_set_filename (gint32 image_ID,
|
||||
char *name);
|
||||
void gimp_image_set_resolution (gint32 image_ID,
|
||||
float resolution);
|
||||
float gimp_image_get_resolution (gint32 image_ID);
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
|
|
|
@ -909,3 +909,40 @@ gimp_image_set_filename (gint32 image_ID,
|
|||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (gint32 image_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
float result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_image_get_resolution",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0.0; /* error return value */
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (gint32 image_ID,
|
||||
float resolution)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_image_set_resolution",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_FLOAT, resolution,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
|
|
@ -909,3 +909,40 @@ gimp_image_set_filename (gint32 image_ID,
|
|||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
||||
float
|
||||
gimp_image_get_resolution (gint32 image_ID)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
float result;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_image_get_resolution",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_END);
|
||||
|
||||
result = 0.0; /* error return value */
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
result = return_vals[1].data.d_float;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_resolution (gint32 image_ID,
|
||||
float resolution)
|
||||
{
|
||||
GParam *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_image_set_resolution",
|
||||
&nreturn_vals,
|
||||
PARAM_IMAGE, image_ID,
|
||||
PARAM_FLOAT, resolution,
|
||||
PARAM_END);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
}
|
||||
|
|
|
@ -307,8 +307,12 @@ static gint32 load_image (char *filename) {
|
|||
}
|
||||
|
||||
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) {
|
||||
g_message("TIFF Can't get photometric");
|
||||
gimp_quit ();
|
||||
g_message("TIFF Can't get photometric\nassuming min-is-black");
|
||||
/* old AppleScan software misses out the photometric tag (and
|
||||
* incidentally assumes min-is-white, but xv assumes min-is-black,
|
||||
* so we follow xv's lead. It's not much hardship to invert the
|
||||
* image later). */
|
||||
photomet = PHOTOMETRIC_MINISBLACK;
|
||||
}
|
||||
|
||||
/* test if the extrasample represents an associated alpha channel... */
|
||||
|
@ -360,6 +364,73 @@ static gint32 load_image (char *filename) {
|
|||
}
|
||||
gimp_image_set_filename (image, filename);
|
||||
|
||||
|
||||
/* any resolution info in the file? */
|
||||
{
|
||||
float xres=0, yres=0;
|
||||
unsigned short units;
|
||||
float res=0.0;
|
||||
|
||||
if (TIFFGetField (tif, TIFFTAG_XRESOLUTION, &xres)) {
|
||||
if (TIFFGetField (tif, TIFFTAG_YRESOLUTION, &yres)) {
|
||||
if (abs(xres - yres) > 1e-5)
|
||||
g_message("TIFF warning: x resolution differs "
|
||||
"from y resolution (%g != %g)\n"
|
||||
"Using x resolution\n", xres, yres);
|
||||
|
||||
res = xres;
|
||||
|
||||
if (TIFFGetField (tif, TIFFTAG_RESOLUTIONUNIT, &units)) {
|
||||
switch(units) {
|
||||
case RESUNIT_NONE:
|
||||
/* ImageMagick writes files with this silly resunit */
|
||||
g_message("TIFF warning: resolution units meaningless, "
|
||||
"forcing 72 dpi\n");
|
||||
res = 72.0;
|
||||
break;
|
||||
|
||||
case RESUNIT_INCH:
|
||||
break;
|
||||
|
||||
case RESUNIT_CENTIMETER:
|
||||
res = ((float)xres) * 2.54;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message("TIFF file error: unknown resolution unit type %d, "
|
||||
"assuming dpi\n", units);
|
||||
}
|
||||
} else { /* no res unit tag */
|
||||
/* old AppleScan software produces these */
|
||||
g_message("TIFF warning: resolution specified without\n"
|
||||
"any units tag, assuming dpi\n");
|
||||
}
|
||||
} else { /* xres but no yres */
|
||||
g_message("TIFF warning: no y resolution info, assuming same as x\n");
|
||||
}
|
||||
|
||||
/* sanity check, since division by zero later could be embarrassing */
|
||||
if (res < 1e-5) {
|
||||
g_message("TIFF: image resolution is zero: forcing 72 dpi\n");
|
||||
res = 72.0;
|
||||
}
|
||||
|
||||
/* now set the new image's resolution info */
|
||||
gimp_image_set_resolution (image, res);
|
||||
}
|
||||
|
||||
/* no x res tag => we assume we have no resolution info, so we
|
||||
* don't care. Older versions of this plugin used to write files
|
||||
* with no resolution tags at all. */
|
||||
|
||||
/* TODO: haven't caught the case where yres tag is present, but
|
||||
not xres. This is left as an exercise for the reader - they
|
||||
should feel free to shoot the author of the broken program
|
||||
that produced the damaged TIFF file in the first place. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Install colormap for INDEXED images only */
|
||||
if (image_type == INDEXED) {
|
||||
if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
|
||||
|
@ -699,6 +770,17 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
|
|||
/* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip ); */
|
||||
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
|
||||
/* resolution fields */
|
||||
{
|
||||
float resolution = gimp_image_get_resolution(image);
|
||||
if (resolution)
|
||||
{
|
||||
TIFFSetField (tif, TIFFTAG_XRESOLUTION, resolution);
|
||||
TIFFSetField (tif, TIFFTAG_YRESOLUTION, resolution);
|
||||
TIFFSetField (tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawable_type == INDEXED_IMAGE)
|
||||
TIFFSetField (tif, TIFFTAG_COLORMAP, red, grn, blu);
|
||||
|
||||
|
|
|
@ -307,8 +307,12 @@ static gint32 load_image (char *filename) {
|
|||
}
|
||||
|
||||
if (!TIFFGetField (tif, TIFFTAG_PHOTOMETRIC, &photomet)) {
|
||||
g_message("TIFF Can't get photometric");
|
||||
gimp_quit ();
|
||||
g_message("TIFF Can't get photometric\nassuming min-is-black");
|
||||
/* old AppleScan software misses out the photometric tag (and
|
||||
* incidentally assumes min-is-white, but xv assumes min-is-black,
|
||||
* so we follow xv's lead. It's not much hardship to invert the
|
||||
* image later). */
|
||||
photomet = PHOTOMETRIC_MINISBLACK;
|
||||
}
|
||||
|
||||
/* test if the extrasample represents an associated alpha channel... */
|
||||
|
@ -360,6 +364,73 @@ static gint32 load_image (char *filename) {
|
|||
}
|
||||
gimp_image_set_filename (image, filename);
|
||||
|
||||
|
||||
/* any resolution info in the file? */
|
||||
{
|
||||
float xres=0, yres=0;
|
||||
unsigned short units;
|
||||
float res=0.0;
|
||||
|
||||
if (TIFFGetField (tif, TIFFTAG_XRESOLUTION, &xres)) {
|
||||
if (TIFFGetField (tif, TIFFTAG_YRESOLUTION, &yres)) {
|
||||
if (abs(xres - yres) > 1e-5)
|
||||
g_message("TIFF warning: x resolution differs "
|
||||
"from y resolution (%g != %g)\n"
|
||||
"Using x resolution\n", xres, yres);
|
||||
|
||||
res = xres;
|
||||
|
||||
if (TIFFGetField (tif, TIFFTAG_RESOLUTIONUNIT, &units)) {
|
||||
switch(units) {
|
||||
case RESUNIT_NONE:
|
||||
/* ImageMagick writes files with this silly resunit */
|
||||
g_message("TIFF warning: resolution units meaningless, "
|
||||
"forcing 72 dpi\n");
|
||||
res = 72.0;
|
||||
break;
|
||||
|
||||
case RESUNIT_INCH:
|
||||
break;
|
||||
|
||||
case RESUNIT_CENTIMETER:
|
||||
res = ((float)xres) * 2.54;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message("TIFF file error: unknown resolution unit type %d, "
|
||||
"assuming dpi\n", units);
|
||||
}
|
||||
} else { /* no res unit tag */
|
||||
/* old AppleScan software produces these */
|
||||
g_message("TIFF warning: resolution specified without\n"
|
||||
"any units tag, assuming dpi\n");
|
||||
}
|
||||
} else { /* xres but no yres */
|
||||
g_message("TIFF warning: no y resolution info, assuming same as x\n");
|
||||
}
|
||||
|
||||
/* sanity check, since division by zero later could be embarrassing */
|
||||
if (res < 1e-5) {
|
||||
g_message("TIFF: image resolution is zero: forcing 72 dpi\n");
|
||||
res = 72.0;
|
||||
}
|
||||
|
||||
/* now set the new image's resolution info */
|
||||
gimp_image_set_resolution (image, res);
|
||||
}
|
||||
|
||||
/* no x res tag => we assume we have no resolution info, so we
|
||||
* don't care. Older versions of this plugin used to write files
|
||||
* with no resolution tags at all. */
|
||||
|
||||
/* TODO: haven't caught the case where yres tag is present, but
|
||||
not xres. This is left as an exercise for the reader - they
|
||||
should feel free to shoot the author of the broken program
|
||||
that produced the damaged TIFF file in the first place. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Install colormap for INDEXED images only */
|
||||
if (image_type == INDEXED) {
|
||||
if (!TIFFGetField (tif, TIFFTAG_COLORMAP, &redmap, &greenmap, &bluemap)) {
|
||||
|
@ -699,6 +770,17 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
|
|||
/* TIFFSetField( tif, TIFFTAG_STRIPBYTECOUNTS, rows / rowsperstrip ); */
|
||||
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||
|
||||
/* resolution fields */
|
||||
{
|
||||
float resolution = gimp_image_get_resolution(image);
|
||||
if (resolution)
|
||||
{
|
||||
TIFFSetField (tif, TIFFTAG_XRESOLUTION, resolution);
|
||||
TIFFSetField (tif, TIFFTAG_YRESOLUTION, resolution);
|
||||
TIFFSetField (tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawable_type == INDEXED_IMAGE)
|
||||
TIFFSetField (tif, TIFFTAG_COLORMAP, red, grn, blu);
|
||||
|
||||
|
|
Loading…
Reference in New Issue