KQuickImageEditor

cropcommand.cpp
1/*
2 * SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#include "cropcommand.h"
8
10 : m_cropRect(cropRect)
11{
12}
13
15{
16 Q_UNUSED(image)
17 return m_image;
18}
19
21{
22 m_image = image;
23 if (m_cropRect.x() < 0) {
24 m_cropRect.setWidth(m_cropRect.width() + m_cropRect.x());
25 m_cropRect.setX(0);
26 }
27 if (m_cropRect.y() < 0) {
28 m_cropRect.setHeight(m_cropRect.height() + m_cropRect.y());
29 m_cropRect.setY(0);
30 }
31 if (m_image.width() < m_cropRect.width() + m_cropRect.x()) {
32 m_cropRect.setWidth(m_image.width() - m_cropRect.x());
33 }
34 if (m_image.height() < m_cropRect.height() + m_cropRect.y()) {
35 m_cropRect.setHeight(m_image.height() - m_cropRect.y());
36 }
37 return m_image.copy(m_cropRect);
38}
QImage undo(QImage image) override
Revert a change to the document.
QImage redo(QImage image) override
Applies the change to the document.
CropCommand(const QRect &cropRect)
Contructor.
QImage copy(const QRect &rectangle) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:25 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.