diff --git a/ArchitectureColoredPainting/src/Editor/LayerManager.cpp b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp index 13de1bc..3634c10 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerManager.cpp +++ b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp @@ -11,9 +11,9 @@ LayerWrapper *LayerManager::getRoot() const { return root; } -void LayerManager::paint(QPainter *painter) const +void LayerManager::paint(QPainter *painter, QSize size) const { - auto p = root->getCache().getPixmap(); + auto p = root->getCache().resizedPixel(size); painter->drawPixmap(0, 0, p); } bool LayerManager::singleSelectedCheck() const diff --git a/ArchitectureColoredPainting/src/Editor/LayerManager.h b/ArchitectureColoredPainting/src/Editor/LayerManager.h index a3a9742..b484047 100644 --- a/ArchitectureColoredPainting/src/Editor/LayerManager.h +++ b/ArchitectureColoredPainting/src/Editor/LayerManager.h @@ -30,8 +30,8 @@ class LayerManager void removeLayer(LayerWrapper *layer); LayerWrapper *getRoot() const; LayerManager() = default; - LayerManager(QJsonObject source, ElementManager *elementManager); - void paint(QPainter *painter) const; + LayerManager(QJsonObject source, ElementManager* elementManager); + void paint(QPainter *painter, QSize size) const; bool rename(QString newName) const; bool combine() const; // bool seperate() const; diff --git a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp index d813867..bb36fcd 100644 --- a/ArchitectureColoredPainting/src/Editor/PixelPath.cpp +++ b/ArchitectureColoredPainting/src/Editor/PixelPath.cpp @@ -73,4 +73,16 @@ PixelPath PixelPath::trans(QTransform& mat)const painter.drawPixmap(0, 0, pixmap); result.boundingRect = mat.mapRect(boundingRect); return result; +} + +QPixmap PixelPath::resizedPixel(QSize size)const +{ + QPixmap result(size); + result.fill(Qt::transparent); + QPainter painter(&result); + + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.setRenderHint(QPainter::HighQualityAntialiasing); + painter.drawPixmap(0, 0, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + return result; } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/PixelPath.h b/ArchitectureColoredPainting/src/Editor/PixelPath.h index 6d82af2..785887c 100644 --- a/ArchitectureColoredPainting/src/Editor/PixelPath.h +++ b/ArchitectureColoredPainting/src/Editor/PixelPath.h @@ -12,8 +12,8 @@ private: QPixmap pixmap; int w,h; public: - PixelPath(int w=2400, int h= 2400); - PixelPath(QPainterPath painterPath,int w = 2400, int h = 2400); + PixelPath(int w=1920, int h= 1080); + PixelPath(QPainterPath painterPath,int w = 1920, int h = 1080); ~PixelPath() = default; QRectF getBoundingRect() const; QPixmap getPixmap() const; @@ -22,4 +22,5 @@ public: void addImage(const QImage& image,const QPointF& pos); void clear(); PixelPath trans(QTransform& mat)const; + QPixmap resizedPixel(QSize size)const; }; \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp index 7a1bb65..53e894c 100644 --- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp +++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.cpp @@ -14,7 +14,7 @@ PreviewWindow::PreviewWindow(QWidget *parent) : QOpenGLWidget(parent) void PreviewWindow::initialize(LayerManager *layerManager,QSize windowSize) { - this->setFixedSize(windowSize); + this->logicalSize = windowSize; this->layerManager = layerManager; } @@ -47,7 +47,7 @@ void PreviewWindow::paintGL() painter->begin(this); painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::HighQualityAntialiasing); - layerManager->paint(painter); + layerManager->paint(painter,this->size()); painter->end(); } diff --git a/ArchitectureColoredPainting/src/Editor/PreviewWindow.h b/ArchitectureColoredPainting/src/Editor/PreviewWindow.h index b907d7f..9a0a4bc 100644 --- a/ArchitectureColoredPainting/src/Editor/PreviewWindow.h +++ b/ArchitectureColoredPainting/src/Editor/PreviewWindow.h @@ -18,6 +18,7 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions QPainter *painter; LayerManager *layerManager; Renderer::ElementRenderer* renderer; + QSize logicalSize; public: PreviewWindow(QWidget *parent = nullptr);