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
int height() const const
int width() const const
int height() const const
void setHeight(int height)
void setWidth(int width)
void setX(int x)
void setY(int y)
int width() const const
int x() const const
int y() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:55:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.