예제 #1
0
void Parser::ParseRefereeMsg(char *msg)
{
	if ( msg[0] == 'y' || msg[0] == 'r' ) ParseCard(msg);
	else ParsePlayMode(msg);
}
예제 #2
0
ieResult ie_fits_Reader::ReadMetaX(volatile bool *pbCancel)
{
	if (pMem->Size() < sizeof(CardImage)) return IE_E_UNKNOWNFILEFORMAT;
	const CardImage *pCard = (CardImage *)pMem->Ptr();

	char	szKeyWord[9], szValue[71];
	ParseCard(pCard++, szKeyWord, szValue);
    if (strcmp(szKeyWord, "SIMPLE") != 0) return IE_E_UNKNOWNFILEFORMAT;
    if (strcmp(szValue, "T") != 0) return IE_E_UNSUPSUBFORMAT;

	PCBYTE pcEnd = pMem->Ptr() + pMem->Size();
	const char *pc;
	nX = nY = nZ = 0;
    dBlank = -123E234L;	// Very unlikely value to occur...

    while (PCBYTE(pCard+1) <= pcEnd) {

    	ParseCard(pCard, szKeyWord, szValue);

        if (strcmp(szKeyWord, "BITPIX") == 0) {
        
			int iZ = ParseInt(szValue);
			bFloats = false;

            switch (iZ) {
            case 8:		// BYTE
            case 16:	// SWORD
            case 32: 	// SDWORD
				nZ = DWORD(iZ);
				break;
			case -32:	// IEEE single precision float
			case -64:	// IEEE double precision float
				nZ = DWORD(-iZ);
				bFloats = true;
				break;
            default:
				return IE_E_UNSUPSUBFORMAT;
            }
        } 
		else if (strcmp(szKeyWord, "NAXIS") == 0) {

        	int j = ParseInt(szValue);
            if (j <= 0) return IE_E_UNSUPSUBFORMAT;
            if (j == 1) return IE_E_UNSUPSUBFORMAT;
        } 
		else if (strcmp(szKeyWord, "NAXIS1") == 0) {

        	nX = ParseInt(szValue);
            if (nX == 0) return IE_E_UNSUPSUBFORMAT;
        } 
		else if (strcmp(szKeyWord, "NAXIS2") == 0) {

        	nY = ParseInt(szValue);
            if (nY == 0) return IE_E_UNSUPSUBFORMAT;
        } 
		else if (strcmp(szKeyWord, "BLANK") == 0) {

        	dBlank = ParseDouble(szValue);
        }
		else if (strcmp(szKeyWord, "OBJECT") == 0) {

			if (*szValue) SetAsRef(ieTextInfoType::Name, pc = pCard->cValue, ParseStrLength(pc, 70));
        }
		else if ((strcmp(szKeyWord, "ORIGIN") == 0) || (strcmp(szKeyWord, "OBSERVER") == 0)) {

			if (*szValue) SetAsRef(ieTextInfoType::Source, pc = pCard->cValue, ParseStrLength(pc, 70));
		} 
		else if (strcmp(szKeyWord, "AUTHOR") == 0) {

			if (*szValue) SetAsRef(ieTextInfoType::Author, pc = pCard->cValue, ParseStrLength(pc, 70));
        } 
		else if (strcmp(szKeyWord, "DATE") == 0) {

			if (*szValue) SetAsRef(ieTextInfoType::CreationDate, pc = pCard->cValue, ParseStrLength(pc, 70));
        } 
		else if (strcmp(szKeyWord, "COMMENT") == 0) {

			if (*szValue && !Have(ieTextInfoType::Comment)) {
				SetAsRef(ieTextInfoType::Comment, (char *)&pCard->cValueSeparator, 71);
			}
		}
		else if (strcmp(szKeyWord, "END") == 0) {

			break;
		}

		pCard++;
    }

    if (!(nX*nY*nZ)) return IE_E_CORRUPTEDFILE;
	
	pf = bFloats ? iePixelFormat::fL : ((nZ > 8) ? iePixelFormat::wL :iePixelFormat::L);
	at = ieAlphaType::None;
	cs = ieColorSpace::L;

	pCard++;
	DWORD cbCards = DWORD(PCBYTE(pCard) - pMem->Ptr());

    int iNumRecords = (cbCards + 2880-1) / 2880;
    pcData = pMem->Ptr() + iNumRecords*2880;

	return IE_S_OK;
}