예제 #1
0
bool ConvertManager::process(const QString & sourcePath)
{
    assert(!m_converter.isNull());
    assert(!m_writer.isNull());
    
    if (!QFile::exists(sourcePath))
    {
        qDebug() << "Input file does not exist.";
        return false;
    }
    
    QImage image(sourcePath);
    if (image.isNull())
    {
        qDebug() << "Loading image from input file failed.";
        return false;
    }

    AssetInformation info;
    info.setProperty("width", image.width());
    info.setProperty("height", image.height());

    for (auto editor : m_editors)
        editor->editImage(image, info);

    QByteArray imageData = m_converter->convert(image, info);

    if (imageData.isEmpty())
        return false;
    
    m_writer->write(imageData, sourcePath, info);

    return true;
}
예제 #2
0
QByteArray Converter::convert(std::unique_ptr<Canvas> & image, AssetInformation & info)
{  
	info.setProperty("format", static_cast<int>(m_format));
	info.setProperty("type", static_cast<int>(m_type));
    
    return image->imageFromTexture(m_format, m_type);
}
예제 #3
0
AssetInformation ConvertManager::generateAssetInformation(const QImage & image)
{
	AssetInformation info;
	info.setProperty("width", image.width());
	info.setProperty("height", image.height());

	return info;
}
예제 #4
0
QByteArray Converter::convert(QImage & image, AssetInformation & info)
{
    m_canvas.loadTextureFromImage(image);
    
    if (hasFragmentShader() && !m_canvas.process(m_fragmentShader, m_uniforms))
        return QByteArray();
    
    info.setProperty("format", QVariant(static_cast<int>(m_format)));
    info.setProperty("type", QVariant(static_cast<int>(m_type)));
    
    return m_canvas.imageFromTexture(m_format, m_type);
}