mirror of https://github.com/GNOME/gimp.git
don't set the resolution to zero
got rid of the compiler warnings in psp.c --Sven
This commit is contained in:
parent
98fcb393b6
commit
440b86e12f
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Sat Jan 8 13:22:15 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gimpimage.c: don't allow to set the resolution to zero
|
||||
|
||||
* plug-ins/bmp/bmpread.c
|
||||
* plug-ins/common/png.c
|
||||
* plug-ins/common/ps.c
|
||||
* plug-ins/common/psp.c
|
||||
* plug-ins/common/tiff.c: Check the resolution before setting it.
|
||||
If it is not valid, do nothing. GIMP will use the default values.
|
||||
|
||||
Fri Jan 7 23:03:51 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/preferences_dialog.c: Doh, how much do I hate to hack this
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -358,6 +358,10 @@ gimp_image_set_resolution (GimpImage *gimage,
|
|||
(ABS (gimage->yresolution - yresolution) < 1e-5))
|
||||
return;
|
||||
|
||||
/* don't allow to set the resolution to zero */
|
||||
if (xresolution < 1e-5 || yresolution < 1e-5)
|
||||
return;
|
||||
|
||||
undo_push_resolution (gimage);
|
||||
|
||||
gimage->xresolution = xresolution;
|
||||
|
|
|
@ -193,7 +193,8 @@ ReadBMP (char *name)
|
|||
xresolution = LROUND((Bitmap_Head.biXPels * 2.54 / 100.0));
|
||||
yresolution = LROUND((Bitmap_Head.biYPels * 2.54 / 100.0));
|
||||
#undef LROUND
|
||||
gimp_image_set_resolution (image_ID, xresolution, yresolution);
|
||||
if (xresolution > 1e-5 && yresolution > 1e-5)
|
||||
gimp_image_set_resolution (image_ID, xresolution, yresolution);
|
||||
}
|
||||
#endif /* GIMP_HAVE_RESOLUTION_INFO */
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ load_image (char *filename) /* I - File to load */
|
|||
|
||||
if (setjmp (pp->jmpbuf))
|
||||
{
|
||||
g_message ("%s\nPNG error. File corrupted?", filename);
|
||||
g_message (_("%s\nPNG error. File corrupted?"), filename);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,8 @@ load_image (char *filename) /* I - File to load */
|
|||
*/
|
||||
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
if (info->valid & PNG_INFO_pHYs)
|
||||
if ((info->valid & PNG_INFO_pHYs) &&
|
||||
(info->x_pixels_per_unit > 1e-5) && (info->y_pixels_per_unit > 1e-5))
|
||||
{
|
||||
if (info->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
gimp_image_set_resolution(image,
|
||||
|
|
|
@ -663,9 +663,12 @@ load_image (char *filename)
|
|||
image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury);
|
||||
if (image_ID == -1) break;
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
gimp_image_set_resolution (image_ID, (float)plvals.resolution,
|
||||
(float)plvals.resolution);
|
||||
gimp_image_set_unit (image_ID, UNIT_INCH);
|
||||
if (plvals.resolution > 1e-5)
|
||||
{
|
||||
gimp_image_set_resolution (image_ID, (float)plvals.resolution,
|
||||
(float)plvals.resolution);
|
||||
gimp_image_set_unit (image_ID, UNIT_INCH);
|
||||
}
|
||||
#endif
|
||||
if (n_images == max_images)
|
||||
{
|
||||
|
|
|
@ -663,9 +663,12 @@ load_image (char *filename)
|
|||
image_ID = load_ps (filename, page_count, ifp, llx, lly, urx, ury);
|
||||
if (image_ID == -1) break;
|
||||
#ifdef GIMP_HAVE_RESOLUTION_INFO
|
||||
gimp_image_set_resolution (image_ID, (float)plvals.resolution,
|
||||
(float)plvals.resolution);
|
||||
gimp_image_set_unit (image_ID, UNIT_INCH);
|
||||
if (plvals.resolution > 1e-5)
|
||||
{
|
||||
gimp_image_set_resolution (image_ID, (float)plvals.resolution,
|
||||
(float)plvals.resolution);
|
||||
gimp_image_set_unit (image_ID, UNIT_INCH);
|
||||
}
|
||||
#endif
|
||||
if (n_images == max_images)
|
||||
{
|
||||
|
|
|
@ -348,17 +348,17 @@ query ()
|
|||
static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
|
||||
static int nload_return_vals = sizeof (load_return_vals) / sizeof (load_return_vals[0]);
|
||||
|
||||
static GParamDef save_args[] =
|
||||
{
|
||||
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ PARAM_IMAGE, "image", "Input image" },
|
||||
{ PARAM_DRAWABLE, "drawable", "Drawable to save" },
|
||||
{ PARAM_STRING, "filename", "The name of the file to save the image in" },
|
||||
{ PARAM_STRING, "raw_filename", "The name of the file to save the image in" },
|
||||
{ PARAM_INT32, "compression", "Specify 0 for no compression, "
|
||||
"1 for RLE, and 2 for LZ77" }
|
||||
};
|
||||
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
|
||||
/* static GParamDef save_args[] = */
|
||||
/* { */
|
||||
/* { PARAM_INT32, "run_mode", "Interactive, non-interactive" }, */
|
||||
/* { PARAM_IMAGE, "image", "Input image" }, */
|
||||
/* { PARAM_DRAWABLE, "drawable", "Drawable to save" }, */
|
||||
/* { PARAM_STRING, "filename", "The name of the file to save the image in" }, */
|
||||
/* { PARAM_STRING, "raw_filename", "The name of the file to save the image in" }, */
|
||||
/* { PARAM_INT32, "compression", "Specify 0 for no compression, " */
|
||||
/* "1 for RLE, and 2 for LZ77" } */
|
||||
/* }; */
|
||||
/* static int nsave_args = sizeof (save_args) / sizeof (save_args[0]); */
|
||||
|
||||
INIT_I18N();
|
||||
|
||||
|
@ -598,13 +598,16 @@ read_block_header (FILE *f,
|
|||
}
|
||||
if (memcmp (buf, "~BK\0", 4) != 0)
|
||||
{
|
||||
g_message ("PSP: Invalid block header at %d", header_start);
|
||||
IFDBG(3)
|
||||
g_message ("PSP: Invalid block header at %ld", header_start);
|
||||
else
|
||||
g_message ("PSP: Invalid block header");
|
||||
|
||||
fclose (f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
IFDBG(3) g_message ("PSP: %s at %d", block_name (id),
|
||||
header_start);
|
||||
IFDBG(3) g_message ("PSP: %s at %ld", block_name (id), header_start);
|
||||
|
||||
if (major < 4)
|
||||
{
|
||||
|
@ -860,6 +863,8 @@ read_creator_block (FILE *f,
|
|||
}
|
||||
|
||||
g_string_free (comment, FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void inline
|
||||
|
@ -1010,9 +1015,10 @@ read_channel_data (FILE *f,
|
|||
GDrawable *drawable,
|
||||
guint32 compressed_len)
|
||||
{
|
||||
gint i, n, x, y, width = drawable->width, height = drawable->height;
|
||||
gint i, y, width = drawable->width, height = drawable->height;
|
||||
gint npixels = width * height;
|
||||
guchar *buf, *buf2, *p, *q, *endq;
|
||||
guchar *buf, *p, *q, *endq;
|
||||
guchar *buf2 = NULL; /* please the compiler */
|
||||
guchar runcount, byte;
|
||||
z_stream zstream;
|
||||
|
||||
|
@ -1131,6 +1137,8 @@ read_channel_data (FILE *f,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1151,7 +1159,7 @@ read_layer_block (FILE *f,
|
|||
gboolean null_layer = FALSE;
|
||||
guint16 bitmap_count, channel_count;
|
||||
GDrawableType drawable_type;
|
||||
guint32 layer_ID;
|
||||
guint32 layer_ID = 0;
|
||||
GLayerMode layer_mode;
|
||||
guint32 channel_init_len, channel_total_len;
|
||||
guint32 compressed_len, uncompressed_len;
|
||||
|
@ -1540,6 +1548,8 @@ read_tube_block (FILE *f,
|
|||
gimp_image_parasite_attach (image_ID, pipe_parasite);
|
||||
parasite_free (pipe_parasite);
|
||||
g_free (parasite_text);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -1555,6 +1565,8 @@ compression_name (int compression)
|
|||
return "LZ77";
|
||||
}
|
||||
g_assert_not_reached ();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gint32
|
||||
|
@ -1566,13 +1578,10 @@ load_image (char *filename)
|
|||
PSPimage ia;
|
||||
guint32 block_init_len, block_total_len;
|
||||
long block_start;
|
||||
PSPBlockID id;
|
||||
PSPBlockID id = -1;
|
||||
gint block_number;
|
||||
|
||||
GPixelRgn pixel_rgn;
|
||||
gint32 image_ID = -1;
|
||||
gint32 layer_ID;
|
||||
GDrawable *drawable;
|
||||
|
||||
if (stat (filename, &st) == -1)
|
||||
return -1;
|
||||
|
@ -1630,7 +1639,7 @@ load_image (char *filename)
|
|||
/* Read all the blocks */
|
||||
block_number = 0;
|
||||
|
||||
IFDBG(3) g_message ("PSP: size = %d", st.st_size);
|
||||
IFDBG(3) g_message ("PSP: size = %d", (int)st.st_size);
|
||||
while (ftell (f) != st.st_size
|
||||
&& (id = read_block_header (f, &block_init_len,
|
||||
&block_total_len)) != -1)
|
||||
|
@ -1660,8 +1669,10 @@ load_image (char *filename)
|
|||
return -1;
|
||||
|
||||
gimp_image_set_filename (image_ID, filename);
|
||||
gimp_image_set_resolution (image_ID, (int) ia.resolution,
|
||||
(int) ia.resolution);
|
||||
|
||||
if ((int) ia.resolution > 1)
|
||||
gimp_image_set_resolution (image_ID,
|
||||
(int) ia.resolution, (int) ia.resolution);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -505,8 +505,7 @@ load_image (char *filename)
|
|||
{
|
||||
case RESUNIT_NONE:
|
||||
/* ImageMagick writes files with this silly resunit */
|
||||
g_message ("TIFF warning: resolution units meaningless, "
|
||||
"forcing 72 dpi\n");
|
||||
g_message ("TIFF warning: resolution units meaningless\n");
|
||||
break;
|
||||
|
||||
case RESUNIT_INCH:
|
||||
|
@ -537,18 +536,16 @@ load_image (char *filename)
|
|||
yres = xres;
|
||||
}
|
||||
|
||||
/* sanity check, since division by zero later could be embarrassing */
|
||||
if (xres < 1e-5 || yres < 1e-5)
|
||||
{
|
||||
g_message ("TIFF: image resolution is zero: forcing 72 dpi\n");
|
||||
xres = 72.0;
|
||||
yres = 72.0;
|
||||
}
|
||||
|
||||
/* now set the new image's resolution info */
|
||||
gimp_image_set_resolution (image, xres, yres);
|
||||
if (unit != UNIT_PIXEL)
|
||||
gimp_image_set_unit (image, unit);
|
||||
|
||||
/* If it is invalid, instead of forcing 72dpi, do not set the resolution
|
||||
at all. Gimp will then use the default set by the user */
|
||||
if (read_unit != RESUNIT_NONE && xres > 1e-5 && yres > 1e-5)
|
||||
{
|
||||
gimp_image_set_resolution (image, xres, yres);
|
||||
if (unit != UNIT_PIXEL)
|
||||
gimp_image_set_unit (image, unit);
|
||||
}
|
||||
}
|
||||
|
||||
/* no x res tag => we assume we have no resolution info, so we
|
||||
|
|
Loading…
Reference in New Issue