Read EXIF properties.
*/
offset=0;
- if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) == 0)
+ if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) != 1)
return;
directory=TIFFCurrentDirectory(tiff);
- if (TIFFReadEXIFDirectory(tiff,offset) == 0)
+ if (TIFFReadEXIFDirectory(tiff,offset) != 1)
{
directory=TIFFCurrentDirectory(tiff);
return;
*ascii;
ascii=(char *) NULL;
- if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) != 0) &&
+ if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) == 1) &&
(ascii != (char *) NULL) && (*ascii != '\0'))
(void) CopyMagickString(value,ascii,MaxTextExtent);
break;
uint16
*shorty;
- if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%d",shorty[0]);
}
else
shorty;
shorty=0;
- if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%d",shorty);
}
break;
longy;
longy=0;
- if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%d",longy);
break;
}
long8y;
long8y=0;
- if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
((MagickOffsetType) long8y));
break;
floaty;
floaty=0.0;
- if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%g",(double) floaty);
break;
}
doubley;
doubley=0.0;
- if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) != 0)
+ if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) == 1)
(void) FormatLocaleString(value,MaxTextExtent,"%g",doubley);
break;
}
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,
&samples_per_pixel);
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units);
- x_resolution=(float) image->resolution.x;
- y_resolution=(float) image->resolution.y;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution);
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution);
- image->resolution.x=x_resolution;
- image->resolution.y=y_resolution;
- x_position=(float) PerceptibleReciprocal(x_resolution)*image->page.x;
- y_position=(float) PerceptibleReciprocal(y_resolution)*image->page.y;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
- image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
- image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation);
- image->orientation=(OrientationType) orientation;
- chromaticity=(float *) NULL;
- (void) TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity);
- if (chromaticity != (float *) NULL)
- {
- image->chromaticity.white_point.x=chromaticity[0];
- image->chromaticity.white_point.y=chromaticity[1];
- }
- chromaticity=(float *) NULL;
- (void) TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity);
- if (chromaticity != (float *) NULL)
- {
- image->chromaticity.red_primary.x=chromaticity[0];
- image->chromaticity.red_primary.y=chromaticity[1];
- image->chromaticity.green_primary.x=chromaticity[2];
- image->chromaticity.green_primary.y=chromaticity[3];
- image->chromaticity.blue_primary.x=chromaticity[4];
- image->chromaticity.blue_primary.y=chromaticity[5];
+ if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution) == 1) &&
+ (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution) == 1))
+ {
+ image->resolution.x=x_resolution;
+ image->resolution.y=y_resolution;
+ }
+ if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position) == 1) &&
+ (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position) == 1))
+ {
+ image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
+ image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
+ }
+ if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation) == 1)
+ image->orientation=(OrientationType) orientation;
+ if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)
+ {
+ if (chromaticity != (float *) NULL)
+ {
+ image->chromaticity.white_point.x=chromaticity[0];
+ image->chromaticity.white_point.y=chromaticity[1];
+ }
+ }
+ if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)
+ {
+ if (chromaticity != (float *) NULL)
+ {
+ image->chromaticity.red_primary.x=chromaticity[0];
+ image->chromaticity.red_primary.y=chromaticity[1];
+ image->chromaticity.green_primary.x=chromaticity[2];
+ image->chromaticity.green_primary.y=chromaticity[3];
+ image->chromaticity.blue_primary.x=chromaticity[4];
+ image->chromaticity.blue_primary.y=chromaticity[5];
+ }
}
#if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)
if ((compress_tag != COMPRESSION_NONE) &&
horizontal,
vertical;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING,
- &horizontal,&vertical);
- (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d",
- horizontal,vertical);
- (void) SetImageProperty(image,"jpeg:sampling-factor",
- sampling_factor,exception);
- (void) LogMagickEvent(CoderEvent,GetMagickModule(),
- "Sampling Factors: %s",sampling_factor);
+ if (TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,&vertical) == 1)
+ {
+ (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d",
+ horizontal,vertical);
+ (void) SetImageProperty(image,"jpeg:sampling-factor",
+ sampling_factor,exception);
+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+ "Sampling Factors: %s",sampling_factor);
+ }
}
#endif
break;
break;
}
associated_alpha=MagickFalse;
- extra_samples=0;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,
- &sample_info);
- if (extra_samples == 0)
+ if (TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,&sample_info) == 1)
{
- if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))
- image->alpha_trait=BlendPixelTrait;
- }
- else
- for (i=0; i < extra_samples; i++)
- {
- image->alpha_trait=BlendPixelTrait;
- if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
- SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
+ if (extra_samples == 0)
+ {
+ if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))
+ image->alpha_trait=BlendPixelTrait;
+ }
+ else
+ for (i=0; i < extra_samples; i++)
+ {
+ image->alpha_trait=BlendPixelTrait;
+ if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
+ SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
+ }
}
option=GetImageOption(image_info,"tiff:alpha");
if (option != (const char *) NULL)
if (units == RESUNIT_CENTIMETER)
image->units=PixelsPerCentimeterResolution;
value=(unsigned short) image->scene;
- (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages);
- image->scene=value;
+ if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages) == 1)
+ image->scene=value;
if (image_info->ping != MagickFalse)
{
if (image_info->number_scenes != 0)
goto next_tiff_frame;
}
method=ReadGenericMethod;
- if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) != 0)
+ if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)
{
char
value[MaxTextExtent];
/*
Initialize colormap.
*/
- red_colormap=(uint16 *) NULL;
- green_colormap=(uint16 *) NULL;
- blue_colormap=(uint16 *) NULL;
- (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
- &green_colormap,&blue_colormap);
- if ((red_colormap != (uint16 *) NULL) &&
- (green_colormap != (uint16 *) NULL) &&
- (blue_colormap != (uint16 *) NULL))
+ if (TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,&green_colormap,&blue_colormap) == 1)
{
- range=255; /* might be old style 8-bit colormap */
- for (i=0; i < (ssize_t) image->colors; i++)
- if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
- (blue_colormap[i] >= 256))
+ if ((red_colormap != (uint16 *) NULL) &&
+ (green_colormap != (uint16 *) NULL) &&
+ (blue_colormap != (uint16 *) NULL))
+ {
+ range=255; /* might be old style 8-bit colormap */
+ for (i=0; i < (ssize_t) image->colors; i++)
+ if ((red_colormap[i] >= 256) ||
+ (green_colormap[i] >= 256) ||
+ (blue_colormap[i] >= 256))
+ {
+ range=65535;
+ break;
+ }
+ for (i=0; i < (ssize_t) image->colors; i++)
{
- range=65535;
- break;
+ image->colormap[i].red=ClampToQuantum(((double)
+ QuantumRange*red_colormap[i])/range);
+ image->colormap[i].green=ClampToQuantum(((double)
+ QuantumRange*green_colormap[i])/range);
+ image->colormap[i].blue=ClampToQuantum(((double)
+ QuantumRange*blue_colormap[i])/range);
}
- for (i=0; i < (ssize_t) image->colors; i++)
- {
- image->colormap[i].red=ClampToQuantum(((double)
- QuantumRange*red_colormap[i])/range);
- image->colormap[i].green=ClampToQuantum(((double)
- QuantumRange*green_colormap[i])/range);
- image->colormap[i].blue=ClampToQuantum(((double)
- QuantumRange*blue_colormap[i])/range);
- }
+ }
}
}
quantum_type=IndexQuantum;
/*
Convert tiled TIFF image to DirectClass MIFF image.
*/
- if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) == 0) ||
- (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) == 0))
+ if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||
+ (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))
{
TIFFClose(tiff);
ThrowReaderException(CoderError,"ImageIsNotTiled");