The document's own pixel budget, marching ants at screen resolution (12.11a)
This commit is contained in:
1 parent
ffba1753c6
commit
8a9c56ee1f
75 files changed
+759
-189
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "IO/PSD/PSDReader.h"
|
||||
#include "Document/DocumentLimits.h"
|
||||
#include "IO/PSD/PSDChannelCoder.h"
|
||||
#include "IO/PSD/PSDVector.h"
|
||||
#include "Logging.h"
|
||||
@@ -222,9 +223,9 @@ void decodeChannels(Cursor &cursor, RawLayer &layer, qint64 remainingPixels)
|
||||
const qint64 width = std::max<qint64>(0, layer.right - layer.left), height = std::max<qint64>(0, layer.bottom - layer.top);
|
||||
const qint64 maskWidth = std::max<qint64>(0, layer.maskRight - layer.maskLeft), maskHeight = std::max<qint64>(0, layer.maskBottom - layer.maskTop);
|
||||
const qint64 budget = std::max<qint64>(0, remainingPixels);
|
||||
if (width > 0 && height > 0 && (width > 30'000 || height > 30'000 || width * height > budget))
|
||||
if (width > 0 && height > 0 && (width > DocumentLimits::maxSide || height > DocumentLimits::maxSide || width * height > budget))
|
||||
throw ImageImportError(ImageImportError::Kind::tooLarge);
|
||||
if (layer.hasMask && maskWidth > 0 && maskHeight > 0 && (maskWidth > 30'000 || maskHeight > 30'000 || maskWidth * maskHeight > budget))
|
||||
if (layer.hasMask && maskWidth > 0 && maskHeight > 0 && (maskWidth > DocumentLimits::maxSide || maskHeight > DocumentLimits::maxSide || maskWidth * maskHeight > budget))
|
||||
throw ImageImportError(ImageImportError::Kind::tooLarge);
|
||||
for (const Channel &channel : layer.channels) {
|
||||
const qint64 start = cursor.offset;
|
||||
@@ -339,7 +340,7 @@ PSDDocument parse(const QByteArray &data, qint64 remainingPixels)
|
||||
cursor.u16();
|
||||
const qint64 canvasHeight = cursor.u32(), canvasWidth = cursor.u32();
|
||||
const int depth = cursor.u16(), mode = cursor.u16();
|
||||
if (canvasWidth < 1 || canvasWidth > 30'000 || canvasHeight < 1 || canvasHeight > 30'000 || canvasWidth * canvasHeight > 100'000'000)
|
||||
if (canvasWidth < 1 || canvasWidth > DocumentLimits::maxSide || canvasHeight < 1 || canvasHeight > DocumentLimits::maxSide || canvasWidth * canvasHeight > DocumentLimits::maxSurfacePixels)
|
||||
throw ImageImportError(ImageImportError::Kind::tooLarge);
|
||||
if (depth != 8)
|
||||
throw PSDError(PSDError::Kind::unsupportedDepth);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "Document/DocumentLimits.h"
|
||||
#include "IO/PSD/PSDTypes.h"
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
@@ -9,8 +10,8 @@
|
||||
namespace PSDReader {
|
||||
bool matches(const QString &path);
|
||||
bool matches(const QByteArray &data);
|
||||
PSDDocument read(const QString &path, qint64 remainingPixels = 100'000'000);
|
||||
PSDDocument read(const QByteArray &data, qint64 remainingPixels = 100'000'000);
|
||||
PSDDocument read(const QString &path, qint64 remainingPixels = DocumentLimits::documentPixelBudget());
|
||||
PSDDocument read(const QByteArray &data, qint64 remainingPixels = DocumentLimits::documentPixelBudget());
|
||||
extern const std::set<QString> adjustmentKeys;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "IO/PSD/PSDVector.h"
|
||||
#include "Document/DocumentLimits.h"
|
||||
#include "Document/BrushStroke.h"
|
||||
#include "Document/EditorSession.h"
|
||||
#include <QPainter>
|
||||
@@ -76,10 +77,10 @@ QRectF integral(const QRectF &box)
|
||||
return QRectF(left, top, std::ceil(box.right()) - left, std::ceil(box.bottom()) - top);
|
||||
}
|
||||
|
||||
// Within 30,000 a side and the pixel budget, else tooLarge.
|
||||
// Within the side limit and the pixel budget, else tooLarge.
|
||||
QSize pixelSize(QSizeF size, qint64 remainingPixels)
|
||||
{
|
||||
if (std::abs(size.width()) > 30'000 || std::abs(size.height()) > 30'000)
|
||||
if (std::abs(size.width()) > DocumentLimits::maxSide || std::abs(size.height()) > DocumentLimits::maxSide)
|
||||
throw ImageImportError(ImageImportError::Kind::tooLarge);
|
||||
const qint64 budget = std::min(EditorSession::maxShapePixels, std::max<qint64>(0, remainingPixels));
|
||||
// Boxes are whole here, so the whole pixels decide alone.
|
||||
@@ -214,7 +215,7 @@ std::optional<PSDVector::Raster> PSDVector::raster(const Extra &extra, QSizeF ca
|
||||
return std::nullopt;
|
||||
if (!std::isfinite(strokeWidth))
|
||||
return std::nullopt;
|
||||
if (strokeEnabled && !(strokeWidth >= 0 && strokeWidth <= 30'000))
|
||||
if (strokeEnabled && !(strokeWidth >= 0 && strokeWidth <= DocumentLimits::maxSide))
|
||||
throw ImageImportError(ImageImportError::Kind::tooLarge);
|
||||
QRectF box = outline->boundingRect();
|
||||
if (strokeEnabled) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "Document/DocumentLimits.h"
|
||||
#include "Document/ShapeTool.h"
|
||||
#include <QByteArray>
|
||||
#include <QImage>
|
||||
@@ -23,8 +24,8 @@ struct Live {
|
||||
|
||||
using Extra = std::map<QString, QByteArray>;
|
||||
|
||||
std::optional<Live> live(const Extra &extra, QSizeF canvas, qint64 remainingPixels = 100'000'000);
|
||||
std::optional<Raster> raster(const Extra &extra, QSizeF canvas, qint64 remainingPixels = 100'000'000);
|
||||
std::optional<Live> live(const Extra &extra, QSizeF canvas, qint64 remainingPixels = DocumentLimits::documentPixelBudget());
|
||||
std::optional<Raster> raster(const Extra &extra, QSizeF canvas, qint64 remainingPixels = DocumentLimits::documentPixelBudget());
|
||||
std::optional<QPainterPath> path(const QByteArray &data, QSizeF canvas);
|
||||
struct RGB {
|
||||
double r;
|
||||
|
||||
Reference in new issue
Block a user