Exemplo n.º 1
0
void
_TIFFSetupFieldInfo(TIFF* tif, const TIFFFieldInfo info[], size_t n)
{
	if (tif->tif_fieldinfo) {
		size_t  i;

		for (i = 0; i < tif->tif_nfields; i++) 
		{
			TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
			if (fld->field_bit == FIELD_CUSTOM && 
				strncmp("Tag ", fld->field_name, 4) == 0) {
					_TIFFfree(fld->field_name);
					_TIFFfree(fld);
				}
		}   
      
		_TIFFfree(tif->tif_fieldinfo);
		tif->tif_nfields = 0;
	}
	if (!_TIFFMergeFieldInfo(tif, info, n))
	{
		TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFieldInfo",
			     "Setting up field info failed");
	}
}
Exemplo n.º 2
0
static void _XTIFFLocalDefaultDirectory(TIFF *tif)
{
	xtiff *xt = XTIFFDIR(tif);
	XTIFFDirectory* xd = &xt->xtif_dir;

	/* Install the extended Tag field info */
	_TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));

	/*
	 *  free up any dynamically allocated arrays
	 *  before the new directory is read in.
	 */
	 
	_XTIFFFreeDirectory(xt);	
	_TIFFmemset(xt,0,sizeof(xtiff));

	/* Override the tag access methods */

	PARENT(xt,vsetfield) =  TIFFMEMBER(tif,vsetfield);
	TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField;
	PARENT(xt,vgetfield) =  TIFFMEMBER(tif,vgetfield);
	TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField;

	/* 
	 * XXX Set up any default values here.
	 */
	
	xd->xd_example_single = 234;
}
Exemplo n.º 3
0
int TIFFInitJBIG(TIFF* tif, int scheme)
{
        JBIGState* codec = NULL;

	assert(scheme == COMPRESSION_JBIG);

	/*
	 * Merge codec-specific tag information.
	 */
	if (!_TIFFMergeFieldInfo(tif, jbigFieldInfo,
				 TIFFArrayCount(jbigFieldInfo))) {
		TIFFErrorExt(tif->tif_clientdata, "TIFFInitJBIG",
			     "Merging JBIG codec-specific tags failed");
		return 0;
	}

        /* Allocate memory for the JBIGState structure.*/
        tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState));
        if (tif->tif_data == NULL)
        {
                TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState");
                return 0;
        }
        _TIFFmemset(tif->tif_data, 0, sizeof(JBIGState));
        codec = GetJBIGState(tif);

        /* Initialize codec private fields */
        codec->recvparams = 0;
        codec->subaddress = NULL;
        codec->faxdcs = NULL;
        codec->recvtime = 0;

	/* 
	 * Override parent get/set field methods.
	 */
        codec->vgetparent = tif->tif_tagmethods.vgetfield;
        codec->vsetparent = tif->tif_tagmethods.vsetfield;
        tif->tif_tagmethods.vgetfield = JBIGVGetField;
        tif->tif_tagmethods.vsetfield = JBIGVSetField;
        tif->tif_tagmethods.printdir = JBIGPrintDir;

        /*
         * These flags are set so the JBIG Codec can control when to reverse
         * bits and when not to and to allow the jbig decoder and bit reverser
         * to write to memory when necessary.
         */
        tif->tif_flags |= TIFF_NOBITREV;
        tif->tif_flags &= ~TIFF_MAPPED;

        /* Setup the function pointers for encode, decode, and cleanup. */
        tif->tif_setupdecode = JBIGSetupDecode;
        tif->tif_decodestrip = JBIGDecode;

        tif->tif_setupencode = JBIGSetupEncode;
        tif->tif_encodestrip = JBIGEncode;
        
        tif->tif_cleanup = JBIGCleanup;

        return 1;
}
int
TIFFInitZIP(TIFF* tif, int scheme)
{
        ZIPState* sp;

        assert( (scheme == COMPRESSION_DEFLATE)
                || (scheme == COMPRESSION_ADOBE_DEFLATE));

        /*
         * Allocate state block so tag methods have storage to record values.
         */
        tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (ZIPState));
        if (tif->tif_data == NULL)
                goto bad;
        sp = ZState(tif);
        sp->stream.zalloc = NULL;
        sp->stream.zfree = NULL;
        sp->stream.opaque = NULL;
        sp->stream.data_type = Z_BINARY;

        /*
         * Merge codec-specific tag information and
         * override parent get/set field methods.
         */
        _TIFFMergeFieldInfo(tif, zipFieldInfo, TIFFArrayCount(zipFieldInfo));
        sp->vgetparent = tif->tif_tagmethods.vgetfield;
        tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
        sp->vsetparent = tif->tif_tagmethods.vsetfield;
        tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */

        /* Default values for codec-specific fields */
        sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
        sp->state = 0;

        /*
         * Install codec methods.
         */
        tif->tif_setupdecode = ZIPSetupDecode;
        tif->tif_predecode = ZIPPreDecode;
        tif->tif_decoderow = ZIPDecode;
        tif->tif_decodestrip = ZIPDecode;
        tif->tif_decodetile = ZIPDecode;
        tif->tif_setupencode = ZIPSetupEncode;
        tif->tif_preencode = ZIPPreEncode;
        tif->tif_postencode = ZIPPostEncode;
        tif->tif_encoderow = ZIPEncode;
        tif->tif_encodestrip = ZIPEncode;
        tif->tif_encodetile = ZIPEncode;
        tif->tif_cleanup = ZIPCleanup;
        /*
         * Setup predictor setup.
         */
        (void) TIFFPredictorInit(tif);
        return (1);
bad:
        TIFFErrorExt(tif->tif_clientdata, "TIFFInitZIP",
                     "No space for ZIP state block");
        return (0);
}
Exemplo n.º 5
0
void
_TIFFSetupFieldInfo(TIFF* tif)
{
	if (tif->tif_fieldinfo) {
		_TIFFfree(tif->tif_fieldinfo);
		tif->tif_nfields = 0;
	}
	_TIFFMergeFieldInfo(tif, tiffFieldInfo, N(tiffFieldInfo));
}
Exemplo n.º 6
0
void
TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n)
{
	if (_TIFFMergeFieldInfo(tif, info, n) < 0)
	{
		TIFFErrorExt(tif->tif_clientdata, "TIFFMergeFieldInfo",
			     "Merging block of %d fields failed", n);
	}
}
Exemplo n.º 7
0
const TIFFFieldInfo*
_TIFFFindOrRegisterFieldInfo( TIFF *tif, ttag_t tag, TIFFDataType dt )

{
    const TIFFFieldInfo *fld;

    fld = _TIFFFindFieldInfo( tif, tag, dt );
    if( fld == NULL )
    {
        fld = _TIFFCreateAnonFieldInfo( tif, tag, dt );
        _TIFFMergeFieldInfo( tif, fld, 1 );
    }

    return fld;
}
Exemplo n.º 8
0
void
_TIFFSetupFieldInfo(TIFF* tif, const TIFFFieldInfo info[], size_t n)
{
	if (tif->tif_fieldinfo) {
		size_t  i;

		for (i = 0; i < tif->tif_nfields; i++) 
		{
			TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
			if (fld->field_bit == FIELD_CUSTOM && 
				strncmp("Tag ", fld->field_name, 4) == 0) {
					_TIFFfree(fld->field_name);
					_TIFFfree(fld);
				}
		}   
      
		_TIFFfree(tif->tif_fieldinfo);
		tif->tif_nfields = 0;
	}
	_TIFFMergeFieldInfo(tif, info, n);
}