-
Notifications
You must be signed in to change notification settings - Fork 45
/
imageeditor.cpp
81 lines (69 loc) · 2.23 KB
/
imageeditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Turbo Rascal Syntax error, “;” expected but “BEGIN” (TRSE, Turbo Rascal SE)
* 8 bit software development IDE for the Commodore 64
* Copyright (C) 2018 Nicolaas Ervik Groeneboom (nicolaas.groeneboom@gmail.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (LICENSE.txt).
* If not, see <https://www.gnu.org/licenses/>.
*/
#include "imageeditor.h"
ImageEdit::ImageEdit(ImageType* t, QString name)
{
//m_imageType = t;
m_fileName = name;
setName();
Initialize();
}
ImageEdit::ImageEdit(LImage* image, ImageType* it, QString name)
{
// m_imageType = it;
m_fileName = name;
setName();
m_image = image;
m_temp = LImageFactory::Create(m_image->m_type,m_image->m_colorList.m_type);
m_temp->Initialize(m_image->m_width, m_image->m_height);
}
void ImageEdit::Initialize()
{
m_image = LImageFactory::Create(m_image->m_type,m_image->m_colorList.m_type);
m_temp = LImageFactory::Create(m_image->m_type,m_image->m_colorList.m_type);
}
void ImageEdit::Initialize(LImage* img)
{
m_image = img;
m_temp = LImageFactory::Create(m_image->m_type,m_image->m_colorList.m_type);
img->ReInitialize();
}
void ImageEdit::Undo()
{
if (m_undo.count()<1)
return;
m_image->CopyFrom(m_undo.last());
m_undo.removeLast();
Data::data.redrawOutput = true;
}
void ImageEdit::AddUndo()
{
m_undo.append(LImageFactory::Create(m_image->m_type, m_image->m_colorList.m_type));
m_undo.last()->CopyFrom(m_image);
if (m_undo.count()>m_undoMax) {
m_undo.removeFirst();
}
}
void ImageEdit::setName()
{
QStringList fs = m_fileName.split("/");
m_name = Util::getFileWithoutEnding((fs[fs.count()-1]));
}