#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QColor>
#include <iostream>
#include <QByteArray>
#include <QDebug>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_cleanPlate_clicked()
{
// load multiple images - must be same dimensions
QStringList filename
= QFileDialog::getOpenFileNames(this, tr
("Choose Image"),
"", tr
("Images (*.png *.jpg *.jpeg *.bmp)"));
uint numberOfImages = static_cast<uint>(filename.count());
QString sizeQuery
= filename.
at(0);
QImage getImageSize
(sizeQuery
);
getImageSize
= getImageSize.
convertToFormat(QImage::Format_RGBA8888);
uint numberOfBytes = static_cast<uint>(getImageSize.sizeInBytes());
std::vector<std::vector<std::vector<uint>>> rgb(numberOfImages, std::vector<std::vector<uint>>(numberOfBytes / 4, std::vector<uint>(4,0)));
std::vector<std::vector<std::vector<uint>>> rgbTranspose(numberOfBytes/4, std::vector<std::vector<uint>>(numberOfImages, std::vector<uint>(4,0)));
// start of nested loop
for (uint i{0};i < numberOfImages;++i) {
image.load(pictures);
image
= image.
convertToFormat(QImage::Format_RGBA8888);
auto const pictureRGBdata = image.bits();
for (uint j{0};j < numberOfBytes/4; ++j) {
std::cout << "Image " << i << ": Pixel: " << j;
for (uint k{0};k < 4;++k) {
rgb[i][j][k] = pictureRGBdata[4*j +k];
std::cout << " " << rgb[i][j][k];
}
std::cout << std::endl;
}
std::cout << std::endl;
}
//end of nested loop - but loop gets stuck here - does not exit loop to next line of code
std::cout << "This won't print ";
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QColor>
#include <iostream>
#include <QByteArray>
#include <QDebug>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_cleanPlate_clicked()
{
// load multiple images - must be same dimensions
QStringList filename = QFileDialog::getOpenFileNames(this, tr("Choose Image"), "", tr("Images (*.png *.jpg *.jpeg *.bmp)"));
uint numberOfImages = static_cast<uint>(filename.count());
QString sizeQuery = filename.at(0);
QImage getImageSize(sizeQuery);
getImageSize = getImageSize.convertToFormat(QImage::Format_RGBA8888);
uint numberOfBytes = static_cast<uint>(getImageSize.sizeInBytes());
std::vector<std::vector<std::vector<uint>>> rgb(numberOfImages, std::vector<std::vector<uint>>(numberOfBytes / 4, std::vector<uint>(4,0)));
std::vector<std::vector<std::vector<uint>>> rgbTranspose(numberOfBytes/4, std::vector<std::vector<uint>>(numberOfImages, std::vector<uint>(4,0)));
// start of nested loop
for (uint i{0};i < numberOfImages;++i) {
QString pictures = filename.at(i);
QImage image(pictures);
image.load(pictures);
image = image.convertToFormat(QImage::Format_RGBA8888);
auto const pictureRGBdata = image.bits();
for (uint j{0};j < numberOfBytes/4; ++j) {
std::cout << "Image " << i << ": Pixel: " << j;
for (uint k{0};k < 4;++k) {
rgb[i][j][k] = pictureRGBdata[4*j +k];
std::cout << " " << rgb[i][j][k];
}
std::cout << std::endl;
}
std::cout << std::endl;
}
//end of nested loop - but loop gets stuck here - does not exit loop to next line of code
std::cout << "This won't print ";
}
To copy to clipboard, switch view to plain text mode
Bookmarks