bool ImageFileHandlerBase::read(      Image        *pImage, 
                                      std::istream &is,
                                const std::string  &mimeType)
{
    ImageFileType *type = getFileType(mimeType.c_str());

    return type == 0 ? false : type->read(pImage, is, mimeType);
}
bool ImageFileHandlerBase::read(      Image *pImage, 
                                const Char8 *fileName,
                                const Char8 *mimeType)
{
    bool        retCode = false;
    std::string fullFilePath;

    if(_pPathHandler != NULL)
    {
        fullFilePath = _pPathHandler->findFile(fileName);
    }
    else
    {
        fullFilePath = fileName;
    }

    if(fullFilePath.empty())
    {
        SWARNING << "couldn't find image file " << fileName << std::endl;
        return false;
    }
    
    ImageFileType *type = getFileType(mimeType, fullFilePath.c_str(), true);
    
    if(type != NULL)
    {
        FDEBUG(("try to image read %s as %s\n", 
                fullFilePath.c_str(), 
                type->getMimeType()));
        
        retCode = type->read(pImage, fullFilePath.c_str());
        
        if(retCode)
        {
            FDEBUG(("image: %dx%d\n", 
                    pImage->getWidth(), 
                    pImage->getHeight()));

            pImage->setAttachmentField(_fileNameKey, fileName);
            pImage->setAttachmentField(_fullFilePathKey, fullFilePath);
			FilePathAttachment::setFilePath(pImage, BoostPath(fullFilePath));


            // converting the path to a absolute path.
            std::string abspath;

            if(fullFilePath[0] != '/'  && 
               fullFilePath[0] != '\\' && 
               fullFilePath[1] != ':')
            {
                std::string base;

                if(getPathHandler() != NULL)
                    base = getPathHandler()->getBaseFile();

                if(base.size() < 2 ||
                   (base[0] != '/' && base[0] != '\\' && base[1] != ':'))
                {
                    const Char8 *cdir = Directory::getCurrent();

                    abspath = cdir;
#ifdef WIN32
                    abspath += '\\';
#else
                    abspath += '/';
#endif
                    delete [] cdir;
                }

                abspath += base;
                abspath += fullFilePath;
            }
            else
            {
                abspath = fullFilePath;
            }

            pImage->setName(abspath);
        }
        else
        {
            SWARNING << "could not read " << fullFilePath << std::endl;
        }
    }
    else
    {
        SWARNING << "could not read " << fullFilePath
                 << "; unknown image format" << std::endl;
    }

    return retCode;
}