/** * Set the spectra-detector map to the buffer workspace. */ void ISISLiveEventDataListener::loadSpectraMap() { // Read in the number of detectors int ndet = getInt("NDET"); // Read in matching arrays of spectra indices and detector ids std::vector<int> udet; std::vector<int> spec; getIntArray("UDET", udet, ndet); getIntArray("SPEC", spec, ndet); // set up the mapping m_eventBuffer[0]->updateSpectraUsing( API::SpectrumDetectorMapping(spec, udet)); }
int main(int argc, char *argv[]) { FILE *fp; int i = 0,out; char line[MAX_INPUT_SIZE]; struct timespec start, end; double cpu_time; int argu [LISTNODE_MAX_LENGTH]; int inputarray_len; fp = fopen(DATA_PATH, "r"); if (fp == NULL) { printf("cannot open the file\n"); return -1; } while (fgets(line, sizeof(line), fp)) { while (line[i] != '\0') i++; line[i - 1] = '\0'; i = 0; inputarray_len = getIntArray(line,argu); assert( inputarray_len < LISTNODE_MAX_LENGTH && "Array length overflow !!!"); clock_gettime(CLOCK_REALTIME, &start); out = maxSubArray(argu,inputarray_len); clock_gettime(CLOCK_REALTIME, &end); cpu_time += diff_in_second(start, end); printf("answer : %d\n",out); } printf("execution time : %lf sec\n", cpu_time); return 0; }
RibLexer::IntArray RibLexerImpl::getIntParam() { if(m_tokenizer.peek().type() == RibToken::INTEGER) { std::vector<int>& buf = m_intArrayPool.getBuf(); buf.push_back(m_tokenizer.get().intVal()); return toRiArray(buf); } return getIntArray(); }
int X3DFIAttributes::getSFInt32(int index) const { std::vector<int> result; getIntArray(getValueAt(index), result); if (result.size() == 1) { return result[0]; } else throw X3DParseException("Wrong size for SFInt32"); }
void X3DFIAttributes::getSFImage(int index, SFImage& value) const { MFInt32 signedVector; SFImage result; getIntArray(getValueAt(index), signedVector); for(MFInt32::const_iterator I = signedVector.begin(); I != signedVector.end(); I++) { result.push_back(static_cast<unsigned int>(*I)); } std::swap(result, value); }
int main(void) { int x[NMAX]; int hmny; hmny = getIntArray(x, NMAX, 0); printf("The array was: \n"); printIntArray(x,hmny); reverseIntArray(x,hmny); printf("after reverse it is:\n"); printIntArray(x,hmny); }
float TiffEntry::getFloat() { if (!(type == TIFF_FLOAT || type == TIFF_DOUBLE || type == TIFF_RATIONAL || type == TIFF_SRATIONAL || type == TIFF_LONG || type == TIFF_SHORT)) ThrowTPE("TIFF, getFloat: Wrong type 0x%x encountered. Expected Float", type); if (type == TIFF_DOUBLE) { return (float)*(double*)&data[0]; } else if (type == TIFF_FLOAT) { return *(float*)&data[0]; } else if (type == TIFF_LONG || type == TIFF_SHORT) { return (float)getInt(); } else if (type == TIFF_RATIONAL) { const unsigned int* t = getIntArray(); if (t[1]) return (float)t[0]/t[1]; } else if (type == TIFF_SRATIONAL) { const int* t = (const int*)getIntArray(); if (t[1]) return (float)t[0]/t[1]; } return 0.0f; }
duk_ret_t nsp_texture_fill_polygon(duk_context *ctx) { duk_require_object_coercible(ctx, 0); int* xys = getIntArray(ctx,0); int nbPts = duk_require_int(ctx, 1); uint16_t color = duk_require_int(ctx, 2); duk_push_this(ctx); duk_get_prop_string(ctx, -1, "width"); int w = duk_require_int(ctx, -1); duk_pop(ctx); duk_get_prop_string(ctx, -1, "height"); int h = duk_require_int(ctx, -1); duk_pop(ctx); if (w <= 0 || h <= 0) { duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "width and height must be positive"); duk_throw(ctx); } duk_get_prop_string(ctx, -1, "bitmap"); size_t size; uint16_t *bitmap = duk_get_buffer(ctx, -1, &size); if (bitmap == NULL) { duk_push_error_object(ctx, DUK_ERR_ERROR, "bitmap pointer is NULL"); duk_throw(ctx); } FbDev* fb = (FbDev*)malloc( 1 * sizeof(FbDev) ); fb->width = w; fb->height = h; fb->fb_size = w * h; fb->fb = bitmap; fillPolygon( xys, nbPts, color, fb ); free(fb); return 0; }
int main(){ int loop = getInt(); int i; for(i=0;i<loop;i++){ int row = getInt(); int color = getInt(); int col = getInt(); int** intArray = getIntArray(row,col); // get array int* perm = malloc(sizeof(int)*(row+1));//allocate row+1 int p; for(p=0;p<row;p++) perm[p] = p; ///generate permutation printPerms(perm,0,color,intArray,col,row); printf("%i\n",counter); freeArray(intArray,col,perm);//free up all mallocs counter = 0; } return 0; }///end of main
int EntityFactory::GetAnimationTime(const RequestAnimationContext& context) { EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src); if ((pSourceEntityView == NULL) || (context.id == 0)) { ASSERT(false); return false; } // 取得配置的多个攻击动作中随机的一个 int nActionId; const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId); int nCount = AttackActId.count; if (nCount == 1) { nActionId = AttackActId.data[0]; } else if (nCount > 1) { int nIndex = getRand(1, nCount); nActionId = AttackActId.data[nIndex - 1]; } else { nActionId = 0; } //if (nActionId == ) //{ //} int nTicks = 0; pSourceEntityView->onCommand(EntityCommand_GetAnimationTime, (ulong)&nTicks, nActionId); return nTicks; }
int proc_vec( int argc, char *argv[], byte first_param ) { float Angles[MAX_VECTOR_SIZE]; float Speeds[MAX_VECTOR_SIZE]; byte Instances[MAX_VECTOR_SIZE]; // GET SPECIFIC INSTANCE NUMBER (255 for all): if (argc < (first_param+1)) { printf( "No vector command.\n"); return 0; } // GET OPERATION TO BE DONE ON INSTANCE: if (strcmp(argv[first_param+1], "clearall") == 0) { // Erase .ini file FILE* f = fopen(VectorFileName,"w"); fprintf(f, " "); fclose(f); printf("Motor Vectors Erased!...\n"); } if (strcmp(argv[first_param+1], "define") == 0) { // Create a Vector (mapping of board instances with indexes) printf("Create Motor Vector...\n"); if (argc < (first_param+3)) { printf( "No vector command.\n"); return 0; } // CONSTRUCT vector: byte size = atoi(argv[first_param+3]); if (size > 50) { printf("Current Max vector size = 50\n"); return 0; } //struct stVector* vector = NewVector( argv[first_param+2], size ); // AssignBoards ( vector, instances ); FILE* f = fopen(VectorFileName,"a+"); fprintf(f, "%s %d ", argv[first_param+2], size); byte instances[50]; for (int i=0; i<size; i++) { if ((i+3) > argc) { printf("Not enough instances!"); return 0; } else { instances[i] = atoi(argv[first_param+4+i]); fprintf( f, "%d ", instances[i] ); } } fprintf( f, "\n"); fclose(f); } if (strcmp(argv[first_param+1], "showall") == 0) { FILE* f = fopen(VectorFileName,"r"); // PRINT .ini file char c = fgetc(f); while (!feof(f)) { printf("%c", c); c = fgetc(f); } fclose(f); } else if (strcmp(argv[first_param+1], "set") == 0) { // GET VECTOR FROM INI File: char* vect_text = readvec( argv[first_param+2] ); if (vect_text == NULL) return 0; //printf("%s\n", vect_text); // Create a Vector (mapping of board instances with indexes) // PARSE SIZE: char* sLine = skipNext( vect_text ); // skip Name byte vsize = atoi( getWord(sLine) ); char* rLine = skipNext( sLine ); // skip size // PARSE INSTANCES: byte size = getIntArray( rLine, Instances ); // The send actually does the AddToSendList() calls for each element if (argc < (vsize*2 + first_param+2)) { printf ("Not enough vectors!"); return 0; } //int argi = 0; // EXTRACT ALL ANGLES & SPEEDS: int i; for (i=0; i<vsize; i++) { Angles[i] = atof(argv[first_param+4+i]); //printf("%9.3f, ", Angles[i]); } //printf("\nSpeeds="); byte s = first_param+4+i; for (i=0; i<vsize; i++) { Speeds[i] = atof(argv[s+i]); //printf("%9.3f ", Speeds[i]); } //printf("\n"); send_angle_vector( vsize, Instances, Angles, Speeds ); } }
const std::string EntityFactory::GetSkillViewAttackAct(uint id) { IntArray AttackActId = getIntArray(id, SkillViewProperty_AttackActId); std::string str = AttackActId.intArrayToString(); return str; }
bool EntityFactory::createSkillTrackEffect(const SkillEffectContext& context) { EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src); if ((pSourceEntityView == NULL) || (context.id == 0)) { ASSERT(false); return false; } // 是否需调整光效方向 long magicAngle = 0; //if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 0) //{ magicAngle = pSourceEntityView->getAngle(); //} //// 生物发起攻击动作 AttackContext ac; // 取得配置的多个攻击动作中随机的一个 int nActionId; const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId); int nCount = AttackActId.count; if (nCount == 1) { nActionId = AttackActId.data[0]; } else if (nCount > 1) { int nIndex = getRand(1, nCount); nActionId = AttackActId.data[nIndex - 1]; } else { nActionId = 0; } ac.actionId = nActionId; ac.loops = context.loops; ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackActSpeed); ac.isSpellAttack = context.isSpellSkill; // 冲锋技能是在瞬移效果完成后再做攻击动作; ulong effectType = getInt(context.id, SkillViewProperty_EffectType); //if (effectType != EffectType_RapidMove && effectType != EffectType_Jump) //{ // pSourceEntityView->onCommand(EntityCommand_Attack, (ulong)&ac); //} // 捆仙索技能在瞬移效果完成后也不需要做攻击动作; if (effectType == EffectType_DestRapidMove || effectType == EffectType_SrcDestRapidMove) { ac.actionId = 0; } ulong magicId = getInt(context.id, SkillViewProperty_TrackMagicId); if (magicId == 0 && (effectType != EffectType_RapidMove && effectType != EffectType_DestRapidMove && effectType != EffectType_SrcDestRapidMove && effectType != EffectType_Jump)) { return true;//(context.id == 1001) ? true : false; } // 创建技能光效; handle magicOwner = context.selectType == 2 ? INVALID_HANDLE : (context.selectType == 0 ? context.src : context.target); switch (effectType) { case EffectType_General: { EffectContext_General ec; ec.magicId = magicId; ec.loops = 1; ec.angle = magicAngle; // 读取一下光效是否绑定在目标上; // 对于通过光效,也使用了SkillViewProperty_ExplodeMagicAttachToTarget来指定光效是否绑定在目标上; int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget); if (nExplodeMagicAttachToTarget == 1) { ec.owner = magicOwner; } else { ec.owner = 0; } ec.tile = context.ptCenter; //return createEffect(EffectType_General, &ec, sizeof(ec)); EffectControl_General* ctrl = new EffectControl_General(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_Fly: { EffectContext_Fly ec; ec.magicId = magicId; ec.angle = magicAngle; ec.loops = -1; ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed); ec.src = context.src; ec.target = context.target; ec.idExplode = getInt(context.id, SkillViewProperty_ExplodeMagicID); // 读取一下爆炸光效是否绑定在目标上; int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget); if (nExplodeMagicAttachToTarget == 1) { ec.hExplodeTarget = context.target; } else { ec.hExplodeTarget = 0; } ec.loopsExplode = 1; ec.ExplodeEffectContext = context; //return createEffect(EffectType_Fly, &ec, sizeof(EffectContext_Fly)); EffectControl_Fly* ctrl = new EffectControl_Fly(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_LifeTime: { EffectContext_LifeTime ec; ec.magicId = magicId; ec.loops = -1; ec.angle = magicAngle; ec.owner = magicOwner;//context.target; ec.tile = context.ptCenter; ec.life = getInt(context.id, SkillViewProperty_LifeTime); //return createEffect(EffectType_LifeTime, &ec, sizeof(ec)); EffectControl_LifeTime* ctrl = new EffectControl_LifeTime(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_MultiTimes: { #if 0 EffectContext_MultiTimes ec; ec.magicId = magicId; ec.loops = 1; ec.angle = magicAngle; ec.tile = context.ptCenter; ec.interval = getInt(context.id, SkillViewProperty_Delay); ec.times = getInt(context.id, SkillViewProperty_Times); ec.owner = magicOwner;//context.target; //return createEffect(EffectType_MultiTimes, &ec, sizeof(EffectContext_MultiTimes)); EffectControl_MultiTimes* ctrl = new EffectControl_MultiTimes(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; #endif } break; case EffectType_Area: { EffectContext_Area ec; ec.magicId = magicId; ec.loops = 1; ec.angle = magicAngle; ec.owner = magicOwner;//0; ec.tile = context.ptCenter; ec.interval = getInt(context.id, SkillViewProperty_Delay); ec.life = getInt(context.id, SkillViewProperty_LifeTime); IntArray& intArray = getIntArray(context.id, SkillViewProperty_AttackRange); ec.arr = &intArray; //return createEffect(EffectType_Area, &ec, sizeof(EffectContext_Area)); EffectControl_Area* ctrl = new EffectControl_Area(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_MultiDir: { const IntArray& arr = getIntArray(context.id, SkillViewProperty_AttackRange); if (arr.count != 3) return false; EffectContext_MultiDir ec; ec.magicId = magicId; ec.loops = -1; ec.angle = magicAngle; ec.owner = context.src; ec.tile = context.ptCenter; ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed); ec.dirs = arr.data[2]; ec.blockType = 0; ec.width = arr.data[0]; ec.maxDist = arr.data[1]; ec.pt = pSourceEntityView->getTile(); //return createEffect(EffectType_MultiDir, &ec, sizeof(EffectContext_MultiDir)); EffectControl_MultiDir* ctrl = new EffectControl_MultiDir(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_RapidMove: { // 创建爆炸光效; int nExplodeMagicID = getInt(context.id, SkillViewProperty_ExplodeMagicID); if (nExplodeMagicID != 0) { EffectContext_General ec; ec.magicId = nExplodeMagicID; ec.loops = 1; ec.angle = magicAngle; // 读取一下爆炸光效是否绑定在目标上; int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget); if (nExplodeMagicAttachToTarget == 1) { ec.owner = context.target; } else { ec.owner = 0; } ec.tile = context.ptTarget; EffectControl_General* ctrl = new EffectControl_General(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); } // 创建瞬移特效; EffectContext_RapidMove ec; ec.magicId = magicId; ec.loops = -1; ec.angle = magicAngle; ec.owner = context.src; ec.tile = context.ptCenter; ec.ac = ac; EffectControl_RapidMove* ctrl = new EffectControl_RapidMove(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_DestRapidMove: { EffectContext_RapidMove ec; ec.magicId = magicId; ec.loops = -1; ec.angle = magicAngle; ec.owner = context.target; ec.tile = context.ptCenter; ec.ac = ac; EffectControl_RapidMove* ctrl = new EffectControl_RapidMove(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; case EffectType_SrcDestRapidMove: { EffectContext_RapidMove ecSrc; ecSrc.magicId = magicId; ecSrc.loops = -1; ecSrc.angle = magicAngle; ecSrc.owner = context.src; ecSrc.tile = context.ptTarget; ecSrc.ac = ac; EffectControl_RapidMove* ctrlSrc = new EffectControl_RapidMove(); if (!ctrlSrc->create(ecSrc)) { delete ctrlSrc; return false; } ctrlSrc->setSrc(context.src); ctrlSrc->setViewId(context.id); EffectControlManager::getInstance().add(ctrlSrc); //return true; // 创建爆炸光效; int nExplodeMagicID = getInt(context.id, SkillViewProperty_ExplodeMagicID); if (nExplodeMagicID != 0) { EffectContext_General ec; ec.magicId = nExplodeMagicID; ec.loops = 1; ec.angle = magicAngle; // 读取一下爆炸光效是否绑定在目标上; int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget); if (nExplodeMagicAttachToTarget == 1) { ec.owner = context.target; } else { ec.owner = 0; } ec.tile = context.ptTarget; EffectControl_General* ctrl = new EffectControl_General(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); } EffectContext_RapidMove ecDest; ecDest.magicId = magicId; ecDest.loops = -1; ecDest.angle = magicAngle; ecDest.owner = context.target; ecDest.tile = context.ptCenter; ecDest.ac = ac; EffectControl_RapidMove* ctrlDest = new EffectControl_RapidMove(); if (!ctrlDest->create(ecDest)) { delete ctrlDest; return false; } ctrlDest->setSrc(context.src); ctrlDest->setViewId(context.id); EffectControlManager::getInstance().add(ctrlDest); return true; } break; //跳跃类 case EffectType_Jump: { EffectContext_RapidMove ec; ec.magicId = magicId; ec.loops = -1; ec.angle = magicAngle; ec.owner = context.src; ec.tile = context.ptCenter; ec.ac = ac; EffectControl_Jump* ctrl = new EffectControl_Jump(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); return true; } break; } return true; }
bool EntityFactory::createSkillAttackEffect(const SkillEffectContext& context) { EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src); if ((pSourceEntityView == NULL) || (context.id == 0)) { ASSERT(false); return false; } // 是否需调整光效方向 long magicAngle = 0; if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 1) { magicAngle = pSourceEntityView->getAngle(); } // 生物发起攻击动作 AttackContext ac; // 取得配置的多个攻击动作中随机的一个 int nActionId; const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId); int nCount = AttackActId.count; if (nCount == 1) { nActionId = AttackActId.data[0]; } else if (nCount > 1) { int nIndex = getRand(1, nCount); nActionId = AttackActId.data[nIndex - 1]; } else { nActionId = 0; } ac.actionId = nActionId; ac.loops = context.loops; ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackActSpeed); ac.isSpellAttack = context.isSpellSkill; // 冲锋技能是在瞬移效果完成后再做攻击动作; ulong effectType = getInt(context.id, SkillViewProperty_EffectType); if ( effectType != EffectType_Jump /*&& effectType != EffectType_RapidMove*/) // modify by zjp;冲锋的过程中做动作 { if (ac.actionId!=0) { //bool bMounted = false; //pSourceEntityView->onCommand(EntityCommand_GetMount, (ulong)&bMounted); //if (bMounted) { pSourceEntityView->onCommand(EntityCommand_SetMount, 0); } pSourceEntityView->onCommand(EntityCommand_Attack, (ulong)&ac); } } // 捆仙索在完成后也不需要做动作 if (effectType == EffectType_DestRapidMove || effectType == EffectType_SrcDestRapidMove) { ac.actionId = 0; } // 施法光效; int nAttackMagicID = getInt(context.id, SkillViewProperty_AttackMagicId); if (nAttackMagicID != 0) { EffectContext_General ec; ec.magicId = nAttackMagicID; ec.loops = 1; ec.angle = magicAngle; // 读取一下光效是否绑定在源上; int nAttackMagicAttachToSource = getInt(context.id, SkillViewProperty_AttackMagicAttachToSource); if (nAttackMagicAttachToSource == 1) { ec.owner = context.src; } else { ec.owner = 0; } // modify by zjp.修改特效释放的位置 //ec.tile = pSourceEntityView->getTile(); ec.tile = context.ptCenter; EffectControl_General* ctrl = new EffectControl_General(); if (!ctrl->create(ec)) { delete ctrl; return false; } ctrl->setSrc(context.src); ctrl->setViewId(context.id); EffectControlManager::getInstance().add(ctrl); } //播放攻击声效 const IntArray & nSoundIDArray = getIntArray(context.id,SkillViewProperty_SoundIDAttack); int nSoundCount = nSoundIDArray.count; int nSoundID = 0; if (nSoundCount == 1) { nSoundID = nSoundIDArray.data[0]; } else if (nSoundCount > 1) { IEntity* pEntity = (IEntity*)pSourceEntityView->getUserData(); if (pEntity && pEntity->GetEntityClass()->IsPerson()) { int PersonSex = pEntity->GetNumProp(CREATURE_PROP_SEX); if (PersonSex == PERSON_SEX_MALE) { nSoundID = nSoundIDArray.data[0]; } else if(PersonSex == PERSON_SEX_FEMALE) { nSoundID = nSoundIDArray.data[1]; } } } int nSoundLoop = getInt(context.id,SkillViewProperty_bSoundLoopeAttack); if (nSoundID>1000) { IFormManager* pFormManger = gGlobalClient->getFormManager(); if (pFormManger) { pFormManger->PlaySound(nSoundID,nSoundLoop,0.8,SOUNDRES_TYPE_SOUND); } } return true; }
void X3DFIAttributes::getMFInt32(int index, MFInt32 &value) const { getIntArray(getValueAt(index), value); }
/*! ************************************************************************ * \brief * Read DirectoryEntry and store important results in 't'. * ************************************************************************ */ static int readDirectoryEntry (Tiff * t) { uint32 tag = t->getU16( t); TiffType type = (TiffType) t->getU16( t); uint32 count = t->getU32( t); uint32 offset = t->getU32( t); switch (tag) { case 256: // ImageWidth SHORT or LONG assert( count == 1); //printf( "256: ImageWidth = %u\n", offset); t->ImageWidth = offset; break; case 257: // ImageLength SHORT or LONG assert( count == 1); //printf( "257: ImageLength = %u\n", offset); t->ImageLength = offset; if (offset > YRES) { fprintf( stderr, "readDirectoryEntry: ImageLength (%d) exceeds builtin maximum of %d\n", offset, YRES); return 1; } break; case 258: // BitsPerSample SHORT 8,8,8 if (count != 3) { fprintf( stderr, "BitsPerSample (only [3] supported)\n"); return 1; } getIntArray( t, offset, type, t->BitsPerSample, 3); //printf( "258: BitsPerSample[%d] = %u,%u,%u\n", count, t->BitsPerSample[0], t->BitsPerSample[1], t->BitsPerSample[2]); if (t->BitsPerSample[0] != t->BitsPerSample[1] || t->BitsPerSample[0] != t->BitsPerSample[2]) { fprintf( stderr, "BitsPerSample must be the same for all samples\n"); return 1; } if (t->BitsPerSample[0] != 8 && t->BitsPerSample[0] != 16) { fprintf( stderr, "Only 8 or 16 BitsPerSample is supported\n"); return 1; } break; case 259: // Compression SHORT 1 or 32773 assert( count == 1); //printf( "259: Compression = %u\n", offset); if (offset != 1) { fprintf( stderr, "Only uncompressed TIFF files supported\n"); return 1; } break; case 262: // PhotometricInterpretation SHORT 2 assert( count == 1); //printf( "262: PhotometricInterpretation = %u\n", offset); assert( offset == 2); break; case 273: // StripOffsets SHORT or LONG //printf( "273: StripOffsets[%d] = %u\n", count, offset); getIntArray( t, offset, type, t->StripOffsets, count); t->nStrips = count; break; case 274: // Orientation SHORT assert( count == 1); //printf( "274: Orientation = %u\n", offset); t->Orientation = (uint16) offset; if (t->Orientation != 1) { fprintf( stderr, "Only Orientation 1 is supported\n"); return 1; } break; case 277: // SamplesPerPixel SHORT 3 or more assert( count == 1); //printf( "277: SamplesPerPixel = %u\n", offset); assert( offset == 3); break; case 278: // RowsPerStrip SHORT or LONG assert( count == 1); //printf( "278: RowsPerStrip = %u\n", offset); t->RowsPerStrip = offset; break; case 279: // StripByteCounts LONG or SHORT //printf( "279: StripByteCounts[%u] = %u\n", count, offset); getIntArray( t, offset, type, t->StripByteCounts, count); break; case 282: // XResolution RATIONAL assert( count == 1); getIntArray( t, offset, type, t->XResolution, 1); //printf( "282: XResolution = %u/%u\n", offset, t->XResolution[0], t->XResolution[1]); break; case 283: // YResolution RATIONAL assert( count == 1); getIntArray( t, offset, type, t->YResolution, 1); //printf( "283: YResolution = %u/%u\n", offset, t->YResolution[0], t->YResolution[1]); break; case 284: // PlanarConfiguration SHORT assert( count == 1); //printf( "284: PlanarConfiguration = %u\n", offset); assert( offset == 1); break; case 296: // ResolutionUnit SHORT 1, 2 or 3 //printf( "296: ResolutionUnit = %u\n", offset); assert( count == 1); break; case 305: // Software ASCII //printf( "305: Software = %s\n", t->fileInMemory + offset); break; case 339: // SampleFormat SHORT 1 default: //printf( "%3d: Unforseen = %u\n", tag, offset); ; } return 0; }