#pragma once #include "Document/BrushStroke.h" #include "Document/DocumentLimits.h" #include "Rendering/RasterSnapshot.h" #include // A layer claiming its size in pixels, holding one. inline ImportedImage claimed(int width, int height, const QString &name = QStringLiteral("Claimed")) { const auto raster = std::make_shared(width, height, BrushRaster::context(1, 1, false), QRectF(0, 0, width, height), std::vector{}); return ImportedImage(raster, QImage(), name); } // Layers claiming `pixels` in all, each within one surface. inline std::vector claiming(qint64 pixels) { std::vector layers; const int side = DocumentLimits::maxSide; while (pixels > 0) { const qint64 rows = std::min(pixels / side, DocumentLimits::maxSurfacePixels / side); layers.push_back(rows > 0 ? claimed(side, int(rows)) : claimed(int(pixels), 1)); pixels -= rows > 0 ? side * rows : pixels; } return layers; }