//------------------------------------------------------------------------------------------------- void sdAnimUIntTrack::SetValue(float fTime, uint uiValue) { sdUIntKey kKey(fTime, IKey::E_KEY_FLAG_CONSTANT, uiValue); int iIndex = FindKey(fTime); if (iIndex == -1) { int iKeyNum = GetNumKeys(); SetNumKeys(iKeyNum + 1); SetKey(iKeyNum, &kKey); SortKeys(); } else { SetKey(iIndex, &kKey); } }
int GTIFWriteKeys(GTIF *gt) { int i; GeoKey *keyptr; KeyEntry *entptr; KeyHeader *header; TempKeyData tempData; int sortkeys[MAX_KEYS]; if (!(gt->gt_flags & FLAG_FILE_MODIFIED)) return 1; if( gt->gt_tif == NULL ) return 0; tempData.tk_asciiParams = 0; tempData.tk_asciiParamsLength = 0; tempData.tk_asciiParamsOffset = 0; /* Sort the Keys into numerical order */ if (!SortKeys(gt,sortkeys)) { /* XXX error: a key was not recognized */ } /* Set up header of ProjectionInfo tag */ header = (KeyHeader *)gt->gt_short; header->hdr_num_keys = (pinfo_t) gt->gt_num_keys; header->hdr_version = GvCurrentVersion; header->hdr_rev_major = GvCurrentRevision; header->hdr_rev_minor = GvCurrentMinorRev; /* Sum up the ASCII tag lengths */ for (i = 0; i < gt->gt_num_keys; i++) { keyptr = gt->gt_keys + sortkeys[i]; if (keyptr->gk_type == TYPE_ASCII) { tempData.tk_asciiParamsLength += keyptr->gk_count; } } if (tempData.tk_asciiParamsLength > 0) { tempData.tk_asciiParams = (char *)_GTIFcalloc(tempData.tk_asciiParamsLength + 1); tempData.tk_asciiParams[tempData.tk_asciiParamsLength] = '\0'; } /* Set up the rest of SHORT array properly */ keyptr = gt->gt_keys; entptr = (KeyEntry*)(gt->gt_short + 4); for (i=0; i< gt->gt_num_keys; i++,entptr++) { if (!WriteKey(gt,&tempData,entptr,keyptr+sortkeys[i])) return 0; } /* Write out the Key Directory */ (gt->gt_methods.set)(gt->gt_tif, GTIFF_GEOKEYDIRECTORY, gt->gt_nshorts, gt->gt_short ); /* Write out the params directories */ if (gt->gt_ndoubles) (gt->gt_methods.set)(gt->gt_tif, GTIFF_DOUBLEPARAMS, gt->gt_ndoubles, gt->gt_double ); if (tempData.tk_asciiParamsLength > 0) { /* just to be safe */ tempData.tk_asciiParams[tempData.tk_asciiParamsLength] = '\0'; (gt->gt_methods.set)(gt->gt_tif, GTIFF_ASCIIPARAMS, 0, tempData.tk_asciiParams); } gt->gt_flags &= ~FLAG_FILE_MODIFIED; if (tempData.tk_asciiParamsLength > 0) { _GTIFFree (tempData.tk_asciiParams); } return 1; }