// ✅ [4] 현재 이미지 UI에 표시
/*void MainWindow::displayCurrentImage()
{
if (currentIndex >= 0 && currentIndex < monoPaths.size()) {
QString monoPath = monoPaths[currentIndex];
QString colorPath = colorPaths[currentIndex];
QPixmap monoPixmap(monoPath);
QPixmap colorPixmap(colorPath);
qDebug() << "[DISPLAY] MONO:" << monoPath;
qDebug() << "[DISPLAY] COLOR:" << colorPath;
// MONO 표시
if (!monoPixmap.isNull()) {
QLayout* layoutMono = ui->frame_MONO->layout();
if (!layoutMono) {
layoutMono = new QVBoxLayout(ui->frame_MONO);
layoutMono->setContentsMargins(0, 0, 0, 0);
ui->frame_MONO->setLayout(layoutMono);
} else {
QLayoutItem* item;
while ((item = layoutMono->takeAt(0)) != nullptr) {
delete item->widget();
delete item;
}
}
QLabel* labelMono = new QLabel(ui->frame_MONO);
labelMono->setPixmap(monoPixmap.scaled(360, 360, Qt::KeepAspectRatio, Qt::SmoothTransformation));
labelMono->setAlignment(Qt::AlignCenter);
layoutMono->addWidget(labelMono);
} else {
qWarning() << "파일 열기 실패: " << monoPath;
}
// COLOR 표시
if (!colorPixmap.isNull()) {
QLayout* layoutColor = ui->frame_COLOR->layout();
if (!layoutColor) {
layoutColor = new QVBoxLayout(ui->frame_COLOR);
layoutColor->setContentsMargins(0, 0, 0, 0);
ui->frame_COLOR->setLayout(layoutColor);
} else {
QLayoutItem* item;
while ((item = layoutColor->takeAt(0)) != nullptr) {
delete item->widget();
delete item;
}
}
QLabel* labelColor = new QLabel(ui->frame_COLOR);
labelColor->setPixmap(colorPixmap.scaled(360, 360, Qt::KeepAspectRatio, Qt::SmoothTransformation));
labelColor->setAlignment(Qt::AlignCenter);
layoutColor->addWidget(labelColor);
} else {
qWarning() << "파일 열기 실패: " << colorPath;
}
}
}
// ✅ [5] 현재 이미지를 서버로 전송 - JSON 포함 패킷 전송 구조 적용
void MainWindow::sendCurrentImageToServer()
{
if (currentIndex >= 0 && currentIndex < monoPaths.size()) {
// [1] MONO 이미지
QString monoPath = monoPaths[currentIndex];
QFile monoFile(monoPath);
if (monoFile.open(QIODevice::ReadOnly)) {
QByteArray monoData = monoFile.readAll();
monoFile.close();
json j;
j["__META__"]["COLOR"] = 0; // MONO
j["__META__"]["SIZE"] = monoData.size();
SocketManager::instance()->sendPacket(1, 1, 0, j, monoData);
qDebug() << "[SEND MONO] size:" << monoData.size();
} else {
qWarning("MONO 파일 열기 실패: %s", qUtf8Printable(monoPath));
}
// [2] COLOR 이미지
QString colorPath = colorPaths[currentIndex];
QFile colorFile(colorPath);
if (colorFile.open(QIODevice::ReadOnly)) {
QByteArray colorData = colorFile.readAll();
colorFile.close();
json j;
j["__META__"]["COLOR"] = 1; // COLOR
j["__META__"]["SIZE"] = colorData.size();
SocketManager::instance()->sendPacket(1, 1, 0, j, colorData);
qDebug() << "[SEND COLOR] size:" << colorData.size();
} else {
qWarning("COLOR 파일 열기 실패: %s", qUtf8Printable(colorPath));
}
}
}*/
주코딩일지