// --------------------------------------------------------------- // Identify // // Examines the data from inSource and determines if it is in a // format that this translator knows how to work with. // // Preconditions: // // Parameters: inSource, where the data to examine is // // inFormat, a hint about the data in inSource, // it is ignored since it is only a hint // // ioExtension, configuration settings for the // translator // // outInfo, information about what data is in // inSource and how well this translator // can handle that data is stored here // // outType, The format that the user wants // the data in inSource to be // converted to // // Postconditions: // // Returns: B_NO_TRANSLATOR, if this translator can't handle // the data in inSource // // B_ERROR, if there was an error converting the data to the host // format // // B_BAD_VALUE, if the settings in ioExtension are bad // // B_OK, if this translator understand the data and there were // no errors found // --------------------------------------------------------------- status_t BaseTranslator::Identify(BPositionIO *inSource, const translation_format *inFormat, BMessage *ioExtension, translator_info *outInfo, uint32 outType) { switch (fTranGroup) { case B_TRANSLATOR_BITMAP: return BitsIdentify(inSource, inFormat, ioExtension, outInfo, outType); default: return DerivedIdentify(inSource, inFormat, ioExtension, outInfo, outType); } }
status_t BaseTranslator::BitsIdentify(BPositionIO *inSource, const translation_format *inFormat, BMessage *ioExtension, translator_info *outInfo, uint32 outType) { status_t result; result = BitsCheck(inSource, ioExtension, outType); if (result == B_OK) result = identify_bits_header(inSource, outInfo); else if (result == B_OK + 1) // if NOT B_TRANSLATOR_BITMAP, it could be an image in the // derived format result = DerivedIdentify(inSource, inFormat, ioExtension, outInfo, outType); return result; }
status_t BaseTranslator::BitsIdentify(BPositionIO *inSource, const translation_format *inFormat, BMessage *ioExtension, translator_info *outInfo, uint32 outType) { status_t result = BitsCheck(inSource, ioExtension, outType); if (result == B_OK) { TranslatorBitmap bitmap; result = identify_bits_header(inSource, outInfo, &bitmap); if (result == B_OK) result = DerivedCanHandleImageSize(bitmap.bounds.Width() + 1.0, bitmap.bounds.Height() + 1.0); } else if (result >= B_OK) { // if NOT B_TRANSLATOR_BITMAP, it could be an image in the // derived format result = DerivedIdentify(inSource, inFormat, ioExtension, outInfo, outType); } return result; }