Skip to content

Commit

Permalink
fix: sending images
Browse files Browse the repository at this point in the history
  • Loading branch information
frank1789 committed Feb 9, 2020
1 parent d2dab00 commit 75a2df1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "mainwindow.hpp"
#include "ui_mainwindow.h"

#include <QColor>
#include <QComboBox>
Expand All @@ -14,6 +13,7 @@

#include "log/logger.h"
#include "palettes.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
Expand Down Expand Up @@ -42,10 +42,10 @@ MainWindow::MainWindow(QWidget *parent)
}
}

client = new TcpClient();
server = new TCPServer();
m_group_all->addLayout(create_label_preview(), 0, 0);
m_group_all->addLayout(create_bar_control(), 0, 1);
m_group_all->addWidget(client, 0, 2);
// m_group_all->addWidget(client, 0, 2);
widget->setLayout(m_group_all);

// connect signal from this to respective classes label
Expand Down Expand Up @@ -75,13 +75,20 @@ MainWindow::MainWindow(QWidget *parent)
// connect Camera to TcpClient
connect(this, &MainWindow::update_rgb_image, [=](QImage image) {
QImage image_resized = image.scaled(512, 512, Qt::KeepAspectRatio);
client->sendImage(image_resized);
QPixmap img = QPixmap::fromImage(image_resized);
QByteArray bImage;
QBuffer bBuffer(&bImage);
// Putting every image in the buffer
bBuffer.open(QIODevice::ReadWrite);
img.save(&bBuffer, "JPG");
// Sending to TCPServer function to display the image
server->is_newImg(bImage);
});
}

MainWindow::~MainWindow() {
delete ui;
delete client;
delete server;
}

void MainWindow::set_thermal_image(QImage img) {
Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QPainter>

#include "mylabel.hpp"
#include "socket/tcpclient.hpp"
#include "socket/tcpserver.h"

QT_BEGIN_NAMESPACE
namespace Ui {
Expand Down Expand Up @@ -154,6 +154,6 @@ class MainWindow : public QMainWindow {
void addOp(QPainter::CompositionMode mode, const QString &name);

// socket client layout
TcpClient *client{nullptr};
TCPServer *server{nullptr};
};
#endif // MAINWINDOW_HPP

0 comments on commit 75a2df1

Please sign in to comment.