Files
OmaPhoto/src/Document/MagicWand.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

41 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <QImage>
#include <QPainterPath>
#include <QPointF>
#include <QString>
#include <optional>
#include <stdexcept>
#include <vector>
// Pixels either side of the click, averaged into the reference.
enum class WandSampleSize { point, threeByThree, fiveByFive };
QString title(WandSampleSize size);
int radius(WandSampleSize size);
// The Magic Wand's options-bar settings.
struct WandSettings {
// How far each channel may differ, 0–255, and still match.
int tolerance = 32;
WandSampleSize sampleSize = WandSampleSize::point;
// Only similar pixels connected to the clicked one.
bool contiguous = true;
// The visible composite rather than the active layer.
bool sampleAllLayers = false;
friend bool operator==(const WandSettings &, const WandSettings &) = default;
};
class MagicWandError : public std::runtime_error {
public:
enum class Kind { tooDetailed, memory };
explicit MagicWandError(Kind kind);
const Kind kind;
};
// Selects pixels like a clicked one; the C kernel matches.
namespace MagicWand {
// The outline of pixels matching the click; nil when none.
std::optional<QPainterPath> select(const QImage &image, QPointF point, const WandSettings &settings);
// The outline of a mask's nonzero pixels along their edges.
std::optional<QPainterPath> outline(const std::vector<uchar> &mask, int width, int height);
}