LRESULT CMainFrame::OnReadJpeg( WPARAM wParam, LPARAM lParam ) { int nSegmentCount = 0; CSegmentData *lpSegmentData = NULL; CSegmentInfo *lpSegmentInfo = NULL; CFileReader FileReader; CJpegAnalyzer JpegAnalyzer; CUserDatas* lpUserDatas = ((CIFuzzMakerDoc*)GetActiveDocument())->GetUserDatas(); lpUserDatas->GetReadBufferArray().RemoveAll(); if( !FileReader.ReadFile( lpUserDatas->GetJpegFileName(), lpUserDatas->GetReadBufferArray() ) ) { // エラー return FALSE; } // Jpeg解析 lpUserDatas->GetSegmentDataArray().RemoveAllWithDelete(); if( !JpegAnalyzer.Analyze( lpUserDatas->GetReadBufferArray(), m_FixedDatas.GetSegmentInfoMap(), lpUserDatas->GetSegmentDataArray() ) ) return FALSE; // Exif解析 for(nSegmentCount=0; nSegmentCount<lpUserDatas->GetSegmentDataArray().GetSize(); nSegmentCount++ ) { lpSegmentData = lpUserDatas->GetSegmentDataArray().GetAt( nSegmentCount ); if( lpSegmentData ) { lpSegmentInfo = lpSegmentData->GetSegmentInfo(); if( lpSegmentInfo ) { if( lpSegmentInfo->GetMarker() == _T("FFE1") ) { CExifAnalyzer ExifAnalyzer; ExifAnalyzer.Analyze( lpUserDatas->GetReadBufferArray().GetSize(), lpSegmentData, &m_FixedDatas.GetImageFileDirectoryInfoMap(), &m_FixedDatas.GetTagTypeInfoMap() ); } if( lpSegmentInfo->IsAnalysisSegment() ) { CSegmentAnalyzer SegmentAnalyzer; SegmentAnalyzer.Analyze( lpUserDatas->GetReadBufferArray().GetSize(), lpSegmentData ); } } } } SendMessageToDescendants( WM_APP_EXIF_ANALYZED, NULL, NULL ); return TRUE; }
LRESULT CMainFrame::OnReadGroup( WPARAM wParam, LPARAM lParam ) { int nGroupCount = 0; CUserDatas* lpUserDatas = ((CIFuzzMakerDoc*)GetActiveDocument())->GetUserDatas(); lpUserDatas->GetPatternGroupDataArray().RemoveAllWithDelete(); CPatternGroupInfoLoader PatternGroupInfoLoader; CPatternGroupInfoArray PatternGroupInfoArray; if( !PatternGroupInfoLoader.LoadText( lpUserDatas->GetGroupFileName(), &PatternGroupInfoArray ) ) return FALSE; for( nGroupCount=0; nGroupCount<PatternGroupInfoArray.GetSize(); nGroupCount++ ) { CPatternGroupInfo *lpPatternGroupInfo = PatternGroupInfoArray.GetAt( nGroupCount ); CPatternInfoLoader PatternInfoLoader; if( !PatternInfoLoader.LoadText( lpPatternGroupInfo->GetFileName(), lpPatternGroupInfo->GetPatternInfoArray() ) ) { } } for( nGroupCount=0; nGroupCount<PatternGroupInfoArray.GetSize(); nGroupCount++ ) { CPatternGroupInfo *lpPatternGroupInfo = PatternGroupInfoArray.GetAt( nGroupCount ); if( lpPatternGroupInfo->GetDispFlag() ) { CPatternGroupData* lpPatternGroupData = NULL; lpUserDatas->GetPatternGroupDataArray().AddWithNew( lpPatternGroupData ); lpPatternGroupData->SetDispName( lpPatternGroupInfo->GetDispName() ); for(int nPatternInfoCnt=0; nPatternInfoCnt<lpPatternGroupInfo->GetPatternInfoArray()->GetSize(); nPatternInfoCnt++ ) { CPatternInfo* lpPatternInfo = lpPatternGroupInfo->GetPatternInfoArray()->GetAt(nPatternInfoCnt); CPatternData* lpPatternData = NULL; CReadBufferArray BinaryDataArray; CStringA szValue = CT2A(lpPatternInfo->GetValue()); BYTE nDecValueByte = 0; unsigned short nDecValueShort = 0; unsigned int nDecValueInteger = 0; unsigned char* lpBuffer = NULL; if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_TEXT ) { // BinaryDataArray.SetSize( szValue.GetLength() * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*szValue.GetLength()], szValue.GetBuffer(), szValue.GetLength() ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_8 ) { nDecValueByte = (BYTE)strtoul( szValue, NULL, 10 ); BinaryDataArray.SetSize( sizeof(nDecValueByte) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueByte)], &nDecValueByte, sizeof(nDecValueByte) ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_16_LITTLE ) { nDecValueShort = (unsigned short)strtoul( szValue, NULL, 10 ); nDecValueShort = CEndianConverter::ConvertToShort( (unsigned char*)&nDecValueShort, FALSE ); BinaryDataArray.SetSize( sizeof(nDecValueShort) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueShort)], &nDecValueShort, sizeof(nDecValueShort) ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_16_BIG ) { nDecValueShort = (unsigned short)strtoul( szValue, NULL, 10 ); nDecValueShort = CEndianConverter::ConvertToShort( (unsigned char*)&nDecValueShort, TRUE ); BinaryDataArray.SetSize( sizeof(nDecValueShort) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueShort)], &nDecValueShort, sizeof(nDecValueShort) ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_32_LITTLE ) { nDecValueInteger = (unsigned int)strtoul( szValue, NULL, 10 ); nDecValueInteger = CEndianConverter::ConvertToInteger( (unsigned char*)&nDecValueInteger, FALSE ); BinaryDataArray.SetSize( sizeof(nDecValueInteger) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueInteger)], &nDecValueInteger, sizeof(nDecValueInteger) ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_32_BIG ) { nDecValueInteger = (unsigned int)strtoul( szValue, NULL, 10 ); nDecValueInteger = CEndianConverter::ConvertToInteger( (unsigned char*)&nDecValueInteger, TRUE ); BinaryDataArray.SetSize( sizeof(nDecValueInteger) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) ); lpBuffer = BinaryDataArray.GetData(); for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ ) { CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueInteger)], &nDecValueInteger, sizeof(nDecValueInteger) ); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_HEX ) { // BinaryDataArray.SetSize( (int)(szValue.GetLength()/2) ); for( int cCnt=0; cCnt<(int)(szValue.GetLength()/2); cCnt++ ) { unsigned int nVal = strtol( szValue.Mid( cCnt*2, 2 ),NULL,16 ); BinaryDataArray.SetAt(cCnt, nVal); } }else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_BIN ) { // CFileReader fl; if( !fl.ReadFile( lpPatternInfo->GetFileName(), BinaryDataArray ) ) continue; } lpPatternGroupData->GetPatternDataArray()->AddWithNew( lpPatternData ); lpPatternData->SetCheck( lpPatternInfo->GetSelectFlag() ); lpPatternData->SetDispName( lpPatternInfo->GetDispName() ); lpPatternData->SetDataType( lpPatternInfo->GetDataType() ); lpPatternData->SetValue( lpPatternInfo->GetValue() ); lpPatternData->SetRepeat( lpPatternInfo->GetRepeat() ); lpPatternData->SetWriteMode( lpPatternInfo->GetWriteMode() ); lpPatternData->SetFuzzArea( lpPatternInfo->GetFuzzArea() ); lpPatternData->SetSearchField( lpPatternInfo->GetSearchField() ); lpPatternData->SetFieldKey( lpPatternInfo->GetFieldKey() ); lpPatternData->SetDescription( lpPatternInfo->GetDescription() ); lpPatternData->SetBinaryDataArray( BinaryDataArray ); if( lpPatternInfo->GetFuzzArea() == CPatternData::FUZZAREA_FILE ) { TCHAR* endptr = NULL; int nFilePos = _tcstol( lpPatternInfo->GetFieldKey(), &endptr, 10 ); if( _tcslen(endptr) ) continue; lpPatternData->SetFilePos( nFilePos ); } if( lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_TAG || lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_TYPE || lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_SEGMENT ) { POSITION pos = NULL; CString szKey; CImageFileDirectoryInfo *lpImageFileDirectoryInfo = NULL; CFealdEntryInfo* lpFealdEntryInfo = NULL; CSegmentItemInfo* lpSegmentItemInfo = NULL; CTagTypeInfo* lpTagTypeInfo = NULL; int nFieldKey = 0; switch(lpPatternData->GetSearchField()) { case CPatternData::SEARCHFIELD_TAG: pos = m_FixedDatas.GetImageFileDirectoryInfoMap().GetStartPosition(); while(pos) { m_FixedDatas.GetImageFileDirectoryInfoMap().GetNextAssoc( pos, szKey, lpImageFileDirectoryInfo ); if( lpImageFileDirectoryInfo->GetFealdEntryInfoMap()->Lookup( lpPatternData->GetFieldKey(), lpFealdEntryInfo ) ) break; } break; case CPatternData::SEARCHFIELD_TYPE: nFieldKey = _tstol(lpPatternData->GetFieldKey()); m_FixedDatas.GetTagTypeInfoMap().Lookup( nFieldKey, lpTagTypeInfo ); break; case CPatternData::SEARCHFIELD_SEGMENT: m_FixedDatas.GetSegmentItemInfoMap().Lookup( lpPatternData->GetFieldKey(), lpSegmentItemInfo ); break; } lpPatternData->SetFealdEntryInfo( lpFealdEntryInfo ); lpPatternData->SetTagTypeInfo( lpTagTypeInfo ); lpPatternData->SetSegmentItemInfo( lpSegmentItemInfo ); } } } } SendMessageToDescendants( WM_APP_GROUP_DISP, NULL, NULL ); return TRUE; }