Ejemplo n.º 1
0
void Gosu::saveImageFile(const Gosu::Bitmap& bitmap, Gosu::Writer writer,
    const std::wstring& formatHint)
{
    int ok;
    
    if (isExtension(formatHint.c_str(), L"bmp"))
    {
        ok = stbi_write_bmp_to_func(stbiWriteToWriter, &writer,
                                    bitmap.width(), bitmap.height(), 4, bitmap.data());
    }
    else if (isExtension(formatHint.c_str(), L"tga"))
    {
        stbi_write_tga_with_rle = 0;
        ok = stbi_write_tga_to_func(stbiWriteToWriter, &writer,
                                    bitmap.width(), bitmap.height(), 4, bitmap.data());
    }
    else
    {
        ok = stbi_write_png_to_func(stbiWriteToWriter, &writer,
                                    bitmap.width(), bitmap.height(), 4, bitmap.data(), 0);
    }
    
    if (ok == 0)
        throw std::runtime_error("Could not save image data to memory (format hint = '" +
                                 Gosu::wstringToUTF8(formatHint) + "'");
}
Ejemplo n.º 2
0
int ebucoreParser::getSchemas(std::string dir, std::vector<std::string> &files)
{
    WIN32_FIND_DATA FindFileData;
    wchar_t * FileName = genericFeatures::string2wchar_t(dir);
    HANDLE hFind = FindFirstFile(FileName, &FindFileData);
    if (isExtension(genericFeatures::wchar_t2string(FindFileData.cFileName), "xsd")) {
        files.push_back(genericFeatures::wchar_t2string(FindFileData.cFileName));
    }
    while (FindNextFile(hFind, &FindFileData)) {
        std::string path(genericFeatures::wchar_t2string(FindFileData.cFileName));
        if (isExtension(path, "xsd")) {
            files.push_back(path);
        }
    }
    return 0;
}
Ejemplo n.º 3
0
void Gosu::saveImageFile(const Gosu::Bitmap& bitmap, const std::wstring& filename)
{
    int ok;
    std::string utf8 = Gosu::wstringToUTF8(filename);
    
    if (isExtension(filename.c_str(), L"bmp"))
    {
        ok = stbi_write_bmp(utf8.c_str(), bitmap.width(), bitmap.height(), 4, bitmap.data());
    }
    else if (isExtension(filename.c_str(), L"tga"))
    {
        ok = stbi_write_tga(utf8.c_str(), bitmap.width(), bitmap.height(), 4, bitmap.data());
    }
    else
    {
        ok = stbi_write_png(utf8.c_str(), bitmap.width(), bitmap.height(), 4, bitmap.data(), 0);
    }
    
    if (ok == 0)
        throw std::runtime_error("Could not save image data to file: " + utf8);
}
Ejemplo n.º 4
0
bool Module::isExtension(const ObjectType& child, const ObjectType& parent) const
{
    if(child.extendsDirectly(parent))
        return true;

    ObjectType father = getFather(child);

    if(!father.isNull())
        return isExtension(father, parent);

    return false;
}
Ejemplo n.º 5
0
// get the path to the schemas
int ebucoreParser::getSchemas (std::string dir, std::vector<std::string> &files) {
    DIR *dp;
    struct dirent *dirp;
    // if opening folder fail then
    if((dp = opendir(dir.c_str())) == NULL) {
        // display error message
        std::cout << "Error(" << errno << ") opening " << dir << std::endl;
        return errno;
    }
    // while not the end of folder
    while ((dirp = readdir(dp)) != NULL) {
        // if it is am xsd file then
        if (dirp->d_type == DT_REG && isExtension(dirp->d_name, "xsd"))
            // save the schema filename inside the vector
            files.push_back(std::string(dirp->d_name));
    }
    closedir(dp); // close folder
    return 0;
}