1
0
Fork 0

Start create python version.

This commit is contained in:
Jarosław Wieczorek 2021-03-08 11:51:01 +01:00
parent 3fe380fd3c
commit 55d0a6d4a9
189 changed files with 42688 additions and 500 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/cpp/skeletonApp/skeletonApp/skeletonApp.cpp" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,48 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyAugmentAssignmentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ourVersions">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="3.7" />
<item index="1" class="java.lang.String" itemvalue="3.8" />
<item index="2" class="java.lang.String" itemvalue="3.9" />
<item index="3" class="java.lang.String" itemvalue="3.10" />
<item index="4" class="java.lang.String" itemvalue="3.10" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyMandatoryEncodingInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyMissingOrEmptyDocstringInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="argparse" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N803" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="anc.models.samples.Sample._meta" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (lpo-image-processing)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

7
.idea/misc.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (lpo-image-processing)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/lpo-image-processing.iml" filepath="$PROJECT_DIR$/.idea/lpo-image-processing.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_150"></TS>

View File

@ -1,484 +1,483 @@
#include <QToolBar>
#include <QIcon>
#include <QClipboard>
#include <QColorSpace>
#include <QDir>
#include <QFileDialog>
#include <QImageReader>
#include <QImageWriter>
#include <QBuffer>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QScreen>
#include <QScrollArea>
#include <QScrollBar>
#include <QStandardPaths>
#include <QStatusBar>
#include <iostream>
#include <fstream>
#include "skeletonApp.h"
skeletonApp::skeletonApp(QWidget *parent)
: QMainWindow(parent), imageLabel(new QLabel)
, scrollArea(new QScrollArea)
{
ui.setupUi(this);
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
scrollArea->setVisible(false);
setCentralWidget(scrollArea);
createActions();
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
}
bool skeletonApp::loadFile(const QString& fileName)
{
data.clear();
QImageReader reader(fileName);
reader.setAutoTransform(true);
const QImage newImage = reader.read();
if (newImage.isNull()) {
QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
tr("Cannot load %1: %2")
.arg(QDir::toNativeSeparators(fileName), reader.errorString()));
return false;
}
//testFilter->setEnabled(true);
filtersMenu->setDisabled(false);
setImage(newImage);
width = image.width();
height = image.height();
int bitPlanes = image.bitPlaneCount();
int depth = image.depth();
QImage::Format format = image.format();
int bytesPerLine = image.bytesPerLine();//niezale¿nie od formatu( pbm, pgm, ppm), wyrównanie do 4B
nbChannels = 1;
if (image.depth() > 1)
nbChannels = image.depth() / 8;
nbRealChannels = 1;
if (image.bitPlaneCount() > 1)
nbRealChannels = image.bitPlaneCount() / 8;
std::ofstream file("test_zapisu.txt", std::ios::out);
if (file.good())
{
for (int i = 0; i < image.height(); i++)
{
std::vector<std::vector<int>> row;
for (int j = 0; j < image.width(); j++)
{
QRgb impix = image.pixel(j, i);//pixel() dzia³a w logice pixel(x,y) - najpierw specyfikuje kolumnê
std::vector<int> pixel;
switch (nbChannels)
{
case 1:
pixel = { qRed(impix) };
file << pixel[0] << " ";
break;
case 3:
pixel = { qRed(impix), qGreen(impix), (int)qBlue(impix) };
file << pixel[0] << " " << pixel[1] << " " << pixel[2];
break;
case 4:
pixel = { qRed(impix), qGreen(impix), qBlue(impix), qAlpha(impix) };
file << pixel[0] << " " << pixel[1] << " " << pixel[2] << " " << pixel[3];
break;
}
file << "\n";
row.push_back(pixel);
}
// file << "\n";
data.push_back(row);
//std::cout << "\n";
}
file.close();
}
setWindowFilePath(fileName);
const QString message = tr("Opened \"%1\", %2x%3, Depth: %4, Bit planes: %5")
.arg(QDir::toNativeSeparators(fileName)).arg(image.width()).arg(image.height()).arg(image.depth()).arg(image.bitPlaneCount());
statusBar()->showMessage(message);
return true;
}
void skeletonApp::setImage(const QImage& newImage)
{
image = newImage;
if (image.colorSpace().isValid())
image.convertToColorSpace(QColorSpace::SRgb);
imageLabel->setPixmap(QPixmap::fromImage(image));
scaleFactor = 1.0;
scrollArea->setVisible(true);
// printAct->setEnabled(true);
fitToWindowAct->setEnabled(true);
updateActions();
if (!fitToWindowAct->isChecked())
imageLabel->adjustSize();
}
void skeletonApp::scaleImage(double factor)
{
scaleFactor *= factor;
imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size());
adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
adjustScrollBar(scrollArea->verticalScrollBar(), factor);
zoomInAct->setEnabled(scaleFactor < 3.0);
zoomOutAct->setEnabled(scaleFactor > 0.333);
}
void skeletonApp::adjustScrollBar(QScrollBar* scrollBar, double factor)
{
scrollBar->setValue(int(factor * scrollBar->value()
+ ((factor - 1) * scrollBar->pageStep() / 2)));
}
void skeletonApp::about()
{
QMessageBox::about(this, tr("About skeletonApp"),
tr("<p>Aplikacja<b> szkieletowa</b> do kursu <i>Przetwarzanie obrazu</i></p>"));
}
bool skeletonApp::saveFile(const QString& fileName)
{
QImageWriter writer(fileName);
if (!writer.write(image)) {
QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
tr("Cannot write %1: %2")
.arg(QDir::toNativeSeparators(fileName)), writer.errorString());
return false;
}
const QString message = tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName));
statusBar()->showMessage(message);
return true;
}
//! [1]
static void initializeImageFileDialog(QFileDialog& dialog, QFileDialog::AcceptMode acceptMode)
{
static bool firstDialog = true;
if (firstDialog) {
firstDialog = false;
const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last());
}
QStringList mimeTypeFilters;
const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
for (const QByteArray& mimeTypeName : supportedMimeTypes)
mimeTypeFilters.append(mimeTypeName);
mimeTypeFilters.sort();
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.selectMimeTypeFilter("image/x-portable-pixmap");
if (acceptMode == QFileDialog::AcceptSave)
dialog.setDefaultSuffix("ppm");
}
void skeletonApp::open()
{
QFileDialog dialog(this, tr("Open File"));
initializeImageFileDialog(dialog, QFileDialog::AcceptOpen);
while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {}
}
//! [1]
void skeletonApp::saveAs()
{
QFileDialog dialog(this, tr("Save File As"));
initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {}
}
void skeletonApp::copy()
{
#ifndef QT_NO_CLIPBOARD
QGuiApplication::clipboard()->setImage(image);
#endif // !QT_NO_CLIPBOARD
}
#ifndef QT_NO_CLIPBOARD
static QImage clipboardImage()
{
if (const QMimeData* mimeData = QGuiApplication::clipboard()->mimeData()) {
if (mimeData->hasImage()) {
const QImage image = qvariant_cast<QImage>(mimeData->imageData());
if (!image.isNull())
return image;
}
}
return QImage();
}
#endif // !QT_NO_CLIPBOARD
void skeletonApp::paste()
{
#ifndef QT_NO_CLIPBOARD
const QImage newImage = clipboardImage();
if (newImage.isNull()) {
statusBar()->showMessage(tr("No image in clipboard"));
}
else {
setImage(newImage);
setWindowFilePath(QString());
const QString message = tr("Obtained image from clipboard, %1x%2, Depth: %3")
.arg(newImage.width()).arg(newImage.height()).arg(newImage.depth());
statusBar()->showMessage(message);
}
#endif // !QT_NO_CLIPBOARD
}
void skeletonApp::zoomIn()
{
scaleImage(1.25);
}
void skeletonApp::zoomOut()
{
scaleImage(0.8);
}
void skeletonApp::normalSize()
{
imageLabel->adjustSize();
scaleFactor = 1.0;
}
void skeletonApp::fitToWindow()
{
bool fitToWindow = fitToWindowAct->isChecked();
scrollArea->setWidgetResizable(fitToWindow);
if (!fitToWindow)
normalSize();
updateActions();
}
void skeletonApp::applyTestFilter()
{
dataResult.clear();
for (int i = 0; i < height; i++)
{
std::vector<std::vector<int>> row;
for (int j = 0; j < width; j++)
{
std::vector<int> pixel;
for (int k = 0; k < nbRealChannels; k++)
{
pixel.push_back(255 - data[i][j][k]);
}//k
if (nbRealChannels < nbChannels)
pixel.push_back(255);
row.push_back(pixel);
}//j
dataResult.push_back(row);
}//i
//uchar* img = new uchar[width * height * nbChannels];
//std::vector<int> img;
//for (int i = 0; i < height; i++)
//{
// for (int j = 0; j < width; j++)
// {
// //std::vector<int> pixel1;
// for (int k = 0; k < nbChannels; k++)
// {
// uchar t;
// t = (uchar)dataResult[i][j][k];
// //img[i * width * nbChannels + j * nbChannels + k] = (uchar)dataResult[i][j][k];
// img.push_back(dataResult[i][j][k]);
// }//k
// }//j
//}//i
//std::ofstream file("test_zapisu_1.txt", std::ios::out);
//if (file.good())
//{
// for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
// {
// for (int j = 0; j < image.width(); j++)
// {
// file << img[i * width + j];
// }
// file << "\n";
// }
// file.close();
//}
//const QByteArray dat = QByteArray::fromRawData(reinterpret_cast<const char*>(img.data()), img.size());
//QBuffer buffer(&dat);
// QImageReader reader(&buffer);
imageResult = QImage(width, height, image.format());
if (nbChannels > 1)
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
imageResult.setPixel(j, i, qRgba(dataResult[i][j][0], dataResult[i][j][1], dataResult[i][j][2], dataResult[i][j][3]));
else
if (image.bitPlaneCount() == 8)
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
imageResult.setPixel(j, i, qRgba(dataResult[i][j][0], dataResult[i][j][0], dataResult[i][j][0],255));
else
{
imageResult.setColorCount(2);
imageResult.setColor(0, qRgba(0, 0, 0, 255)); // Index #0 = Red
imageResult.setColor(1, qRgba(255, 0, 0, 0));
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
{
if (dataResult[i][j][0] == 0)
imageResult.setPixel(j, i, 0);
else
imageResult.setPixel(j, i, 1);
}
}
//imageResult = QImage(img,width,height,image.format());
setImage(imageResult);
}
void skeletonApp::updateActions()
{
saveAsAct->setEnabled(!image.isNull());
copyAct->setEnabled(!image.isNull());
zoomInAct->setEnabled(!fitToWindowAct->isChecked());
zoomOutAct->setEnabled(!fitToWindowAct->isChecked());
normalSizeAct->setEnabled(!fitToWindowAct->isChecked());
}
void skeletonApp::createActions()
{
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
QAction* openAct = fileMenu->addAction(tr("&Open..."), this, &skeletonApp::open);
openAct->setShortcut(QKeySequence::Open);
saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &skeletonApp::saveAs);
saveAsAct->setEnabled(false);
fileMenu->addSeparator();
QAction* exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
exitAct->setShortcut(tr("Ctrl+Q"));
QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
copyAct = editMenu->addAction(tr("&Copy"), this, &skeletonApp::copy);
copyAct->setShortcut(QKeySequence::Copy);
copyAct->setEnabled(false);
QAction* pasteAct = editMenu->addAction(tr("&Paste"), this, &skeletonApp::paste);
pasteAct->setShortcut(QKeySequence::Paste);
QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
zoomInAct = viewMenu->addAction(tr("Zoom &In (25%)"), this, &skeletonApp::zoomIn);
zoomInAct->setShortcut(QKeySequence::ZoomIn);
zoomInAct->setEnabled(false);
zoomOutAct = viewMenu->addAction(tr("Zoom &Out (25%)"), this, &skeletonApp::zoomOut);
zoomOutAct->setShortcut(QKeySequence::ZoomOut);
zoomOutAct->setEnabled(false);
normalSizeAct = viewMenu->addAction(tr("&Normal Size"), this, &skeletonApp::normalSize);
normalSizeAct->setShortcut(tr("Ctrl+S"));
normalSizeAct->setEnabled(false);
viewMenu->addSeparator();
fitToWindowAct = viewMenu->addAction(tr("&Fit to Window"), this, &skeletonApp::fitToWindow);
fitToWindowAct->setEnabled(false);
fitToWindowAct->setCheckable(true);
fitToWindowAct->setShortcut(tr("Ctrl+F"));
filtersMenu = menuBar()->addMenu(tr("&Filters"));
filtersMenu->setDisabled(true);
testFilter = filtersMenu->addAction(tr("&TestFilter"), this, &skeletonApp::applyTestFilter);
//testFilter->setDisabled(true);
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(tr("&About"), this, &skeletonApp::about);
}
#include <QToolBar>
#include <QIcon>
#include <QClipboard>
#include <QColorSpace>
#include <QDir>
#include <QFileDialog>
#include <QImageReader>
#include <QImageWriter>
#include <QBuffer>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QScreen>
#include <QScrollArea>
#include <QScrollBar>
#include <QStandardPaths>
#include <QStatusBar>
#include <iostream>
#include <fstream>
#include "skeletonApp.h"
skeletonApp::skeletonApp(QWidget *parent): QMainWindow(parent),
imageLabel(new QLabel), scrollArea(new QScrollArea)
{
ui.setupUi(this);
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
scrollArea->setVisible(false);
setCentralWidget(scrollArea);
createActions();
resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5);
}
bool skeletonApp::loadFile(const QString& fileName)
{
data.clear();
QImageReader reader(fileName);
reader.setAutoTransform(true);
const QImage newImage = reader.read();
if (newImage.isNull()) {
QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
tr("Cannot load %1: %2")
.arg(QDir::toNativeSeparators(fileName), reader.errorString()));
return false;
}
//testFilter->setEnabled(true);
filtersMenu->setDisabled(false);
setImage(newImage);
width = image.width();
height = image.height();
int bitPlanes = image.bitPlaneCount();
int depth = image.depth();
QImage::Format format = image.format();
int bytesPerLine = image.bytesPerLine();//niezale<6C>nie od formatu( pbm, pgm, ppm), wyr<79>wnanie do 4B
nbChannels = 1;
if (image.depth() > 1)
nbChannels = image.depth() / 8;
nbRealChannels = 1;
if (image.bitPlaneCount() > 1)
nbRealChannels = image.bitPlaneCount() / 8;
std::ofstream file("test_zapisu.txt", std::ios::out);
if (file.good())
{
for (int i = 0; i < image.height(); i++)
{
std::vector<std::vector<int>> row;
for (int j = 0; j < image.width(); j++)
{
QRgb impix = image.pixel(j, i);//pixel() dzia<69>a w logice pixel(x,y) - najpierw specyfikuje kolumn<6D>
std::vector<int> pixel;
switch (nbChannels)
{
case 1:
pixel = { qRed(impix) };
file << pixel[0] << " ";
break;
case 3:
pixel = { qRed(impix), qGreen(impix), (int)qBlue(impix) };
file << pixel[0] << " " << pixel[1] << " " << pixel[2];
break;
case 4:
pixel = { qRed(impix), qGreen(impix), qBlue(impix), qAlpha(impix) };
file << pixel[0] << " " << pixel[1] << " " << pixel[2] << " " << pixel[3];
break;
}
file << "\n";
row.push_back(pixel);
}
// file << "\n";
data.push_back(row);
//std::cout << "\n";
}
file.close();
}
setWindowFilePath(fileName);
const QString message = tr("Opened \"%1\", %2x%3, Depth: %4, Bit planes: %5")
.arg(QDir::toNativeSeparators(fileName)).arg(image.width()).arg(image.height()).arg(image.depth()).arg(image.bitPlaneCount());
statusBar()->showMessage(message);
return true;
}
void skeletonApp::setImage(const QImage& newImage)
{
image = newImage;
if (image.colorSpace().isValid())
image.convertToColorSpace(QColorSpace::SRgb);
imageLabel->setPixmap(QPixmap::fromImage(image));
scaleFactor = 1.0;
scrollArea->setVisible(true);
// printAct->setEnabled(true);
fitToWindowAct->setEnabled(true);
updateActions();
if (!fitToWindowAct->isChecked())
imageLabel->adjustSize();
}
void skeletonApp::scaleImage(double factor)
{
scaleFactor *= factor;
imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size());
adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
adjustScrollBar(scrollArea->verticalScrollBar(), factor);
zoomInAct->setEnabled(scaleFactor < 3.0);
zoomOutAct->setEnabled(scaleFactor > 0.333);
}
void skeletonApp::adjustScrollBar(QScrollBar* scrollBar, double factor)
{
scrollBar->setValue(int(factor * scrollBar->value()
+ ((factor - 1) * scrollBar->pageStep() / 2)));
}
void skeletonApp::about()
{
QMessageBox::about(this, tr("About skeletonApp"),
tr("<p>Aplikacja<b> szkieletowa</b> do kursu <i>Przetwarzanie obrazu</i></p>"));
}
bool skeletonApp::saveFile(const QString& fileName)
{
QImageWriter writer(fileName);
if (!writer.write(image)) {
QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
tr("Cannot write %1: %2")
.arg(QDir::toNativeSeparators(fileName)), writer.errorString());
return false;
}
const QString message = tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName));
statusBar()->showMessage(message);
return true;
}
//! [1]
static void initializeImageFileDialog(QFileDialog& dialog, QFileDialog::AcceptMode acceptMode)
{
static bool firstDialog = true;
if (firstDialog) {
firstDialog = false;
const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last());
}
QStringList mimeTypeFilters;
const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
for (const QByteArray& mimeTypeName : supportedMimeTypes)
mimeTypeFilters.append(mimeTypeName);
mimeTypeFilters.sort();
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.selectMimeTypeFilter("image/x-portable-pixmap");
if (acceptMode == QFileDialog::AcceptSave)
dialog.setDefaultSuffix("ppm");
}
void skeletonApp::open()
{
QFileDialog dialog(this, tr("Open File"));
initializeImageFileDialog(dialog, QFileDialog::AcceptOpen);
while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {}
}
//! [1]
void skeletonApp::saveAs()
{
QFileDialog dialog(this, tr("Save File As"));
initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {}
}
void skeletonApp::copy()
{
#ifndef QT_NO_CLIPBOARD
QGuiApplication::clipboard()->setImage(image);
#endif // !QT_NO_CLIPBOARD
}
#ifndef QT_NO_CLIPBOARD
static QImage clipboardImage()
{
if (const QMimeData* mimeData = QGuiApplication::clipboard()->mimeData()) {
if (mimeData->hasImage()) {
const QImage image = qvariant_cast<QImage>(mimeData->imageData());
if (!image.isNull())
return image;
}
}
return QImage();
}
#endif // !QT_NO_CLIPBOARD
void skeletonApp::paste()
{
#ifndef QT_NO_CLIPBOARD
const QImage newImage = clipboardImage();
if (newImage.isNull()) {
statusBar()->showMessage(tr("No image in clipboard"));
}
else {
setImage(newImage);
setWindowFilePath(QString());
const QString message = tr("Obtained image from clipboard, %1x%2, Depth: %3")
.arg(newImage.width()).arg(newImage.height()).arg(newImage.depth());
statusBar()->showMessage(message);
}
#endif // !QT_NO_CLIPBOARD
}
void skeletonApp::zoomIn()
{
scaleImage(1.25);
}
void skeletonApp::zoomOut()
{
scaleImage(0.8);
}
void skeletonApp::normalSize()
{
imageLabel->adjustSize();
scaleFactor = 1.0;
}
void skeletonApp::fitToWindow()
{
bool fitToWindow = fitToWindowAct->isChecked();
scrollArea->setWidgetResizable(fitToWindow);
if (!fitToWindow)
normalSize();
updateActions();
}
void skeletonApp::applyTestFilter()
{
dataResult.clear();
for (int i = 0; i < height; i++)
{
std::vector<std::vector<int>> row;
for (int j = 0; j < width; j++)
{
std::vector<int> pixel;
for (int k = 0; k < nbRealChannels; k++)
{
pixel.push_back(255 - data[i][j][k]);
}//k
if (nbRealChannels < nbChannels)
pixel.push_back(255);
row.push_back(pixel);
}//j
dataResult.push_back(row);
}//i
//uchar* img = new uchar[width * height * nbChannels];
//std::vector<int> img;
//for (int i = 0; i < height; i++)
//{
// for (int j = 0; j < width; j++)
// {
// //std::vector<int> pixel1;
// for (int k = 0; k < nbChannels; k++)
// {
// uchar t;
// t = (uchar)dataResult[i][j][k];
// //img[i * width * nbChannels + j * nbChannels + k] = (uchar)dataResult[i][j][k];
// img.push_back(dataResult[i][j][k]);
// }//k
// }//j
//}//i
//std::ofstream file("test_zapisu_1.txt", std::ios::out);
//if (file.good())
//{
// for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
// {
// for (int j = 0; j < image.width(); j++)
// {
// file << img[i * width + j];
// }
// file << "\n";
// }
// file.close();
//}
//const QByteArray dat = QByteArray::fromRawData(reinterpret_cast<const char*>(img.data()), img.size());
//QBuffer buffer(&dat);
// QImageReader reader(&buffer);
imageResult = QImage(width, height, image.format());
if (nbChannels > 1)
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
imageResult.setPixel(j, i, qRgba(dataResult[i][j][0], dataResult[i][j][1], dataResult[i][j][2], dataResult[i][j][3]));
else
if (image.bitPlaneCount() == 8)
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
imageResult.setPixel(j, i, qRgba(dataResult[i][j][0], dataResult[i][j][0], dataResult[i][j][0],255));
else
{
imageResult.setColorCount(2);
imageResult.setColor(0, qRgba(0, 0, 0, 255)); // Index #0 = Red
imageResult.setColor(1, qRgba(255, 0, 0, 0));
for (int i = 0; i < image.height(); i++)//obraz jest w pliku zapisany
for (int j = 0; j < image.width(); j++)
{
if (dataResult[i][j][0] == 0)
imageResult.setPixel(j, i, 0);
else
imageResult.setPixel(j, i, 1);
}
}
//imageResult = QImage(img,width,height,image.format());
setImage(imageResult);
}
void skeletonApp::updateActions()
{
saveAsAct->setEnabled(!image.isNull());
copyAct->setEnabled(!image.isNull());
zoomInAct->setEnabled(!fitToWindowAct->isChecked());
zoomOutAct->setEnabled(!fitToWindowAct->isChecked());
normalSizeAct->setEnabled(!fitToWindowAct->isChecked());
}
void skeletonApp::createActions()
{
QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
QAction* openAct = fileMenu->addAction(tr("&Open..."), this, &skeletonApp::open);
openAct->setShortcut(QKeySequence::Open);
saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &skeletonApp::saveAs);
saveAsAct->setEnabled(false);
fileMenu->addSeparator();
QAction* exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
exitAct->setShortcut(tr("Ctrl+Q"));
QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
copyAct = editMenu->addAction(tr("&Copy"), this, &skeletonApp::copy);
copyAct->setShortcut(QKeySequence::Copy);
copyAct->setEnabled(false);
QAction* pasteAct = editMenu->addAction(tr("&Paste"), this, &skeletonApp::paste);
pasteAct->setShortcut(QKeySequence::Paste);
QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
zoomInAct = viewMenu->addAction(tr("Zoom &In (25%)"), this, &skeletonApp::zoomIn);
zoomInAct->setShortcut(QKeySequence::ZoomIn);
zoomInAct->setEnabled(false);
zoomOutAct = viewMenu->addAction(tr("Zoom &Out (25%)"), this, &skeletonApp::zoomOut);
zoomOutAct->setShortcut(QKeySequence::ZoomOut);
zoomOutAct->setEnabled(false);
normalSizeAct = viewMenu->addAction(tr("&Normal Size"), this, &skeletonApp::normalSize);
normalSizeAct->setShortcut(tr("Ctrl+S"));
normalSizeAct->setEnabled(false);
viewMenu->addSeparator();
fitToWindowAct = viewMenu->addAction(tr("&Fit to Window"), this, &skeletonApp::fitToWindow);
fitToWindowAct->setEnabled(false);
fitToWindowAct->setCheckable(true);
fitToWindowAct->setShortcut(tr("Ctrl+F"));
filtersMenu = menuBar()->addMenu(tr("&Filters"));
filtersMenu->setDisabled(true);
testFilter = filtersMenu->addAction(tr("&TestFilter"), this, &skeletonApp::applyTestFilter);
//testFilter->setDisabled(true);
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(tr("&About"), this, &skeletonApp::about);
}

View File

@ -0,0 +1,27 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++20
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
skeletonApp.cpp
HEADERS += \
skeletonApp.h
FORMS += \
skeletonApp.ui
TRANSLATIONS += \
SkeletonApp_en_150.ts
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@ -1,2 +1,2 @@
Jarosław Wieczorek
Mateusz Winnicki
Jagoda Jarowicz

View File

@ -1,15 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pyqt6 = "*"
pip = "*"
pyqt6-sip = "*"
pyqt5 = "*"
[dev-packages]
[requires]
python_version = "3.9"

2
python/__init__.py Normal file
View File

@ -0,0 +1,2 @@
"""Import classes"""
from skeletonApp import SkeletonApp

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 968 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Some files were not shown because too many files have changed in this diff Show More