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; }
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); }
AssetInformation ConvertManager::generateAssetInformation(const QImage & image) { AssetInformation info; info.setProperty("width", image.width()); info.setProperty("height", image.height()); return info; }
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); }