Files
OmaPhoto/src/IO/ImageExporter.h
T
雷电芽衣andClaude c864304695
Release / deb (push) Canceled after 0s
Release / rpm (push) Canceled after 0s
Release / arch (push) Canceled after 0s
Release / publish (push) Canceled after 0s
OmaPhoto 1.0.0: the Linux port of Compositor
A layered image editor for Linux and Omarchy, ported from Compositor
(github.com/robbietilton/Compositor), whose Swift source is its
specification. It reads and writes Compositor's .comp projects.

Packages for Ubuntu, Fedora and Arch come from the release workflow;
scripts/install/ holds one install script per distribution family,
and flake.nix serves NixOS.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-26 00:44:52 -04:00

48 lines
1.3 KiB
C++

#pragma once
#include "IO/ProjectStore.h"
#include <QByteArray>
#include <QImage>
#include <functional>
#include <stdexcept>
class ExportError : public std::runtime_error {
public:
enum class Kind { tooLarge, render, encode };
explicit ExportError(Kind kind);
const Kind kind;
};
// Swift's CancellationError: a newer request superseded this one.
class CancellationError : public std::exception {};
struct ExportRaster {
QImage image;
// Pixels per inch.
double resolution = 72;
};
struct JPEGOptions {
double quality = 0.85;
// The matte behind transparent pixels.
double red = 1;
double green = 1;
double blue = 1;
bool operator==(const JPEGOptions &) const = default;
};
struct JPEGResult {
QByteArray data;
// Decoded from `data`, at most 1000 pixels a side.
QImage preview;
};
namespace ImageExporter {
ExportRaster render(const ProjectSnapshot &snapshot);
QByteArray pngData(const ProjectSnapshot &snapshot);
// Stops at Swift's three points once `cancelled` says so.
JPEGResult jpeg(const ExportRaster &raster, const JPEGOptions &options, const std::function<bool()> &cancelled = {});
void exportPNG(const ProjectSnapshot &snapshot, const QString &path);
// Replaces the file in one step, or not at all.
void write(const QByteArray &data, const QString &path);
}