Commit babfad35 authored by Andy Regensky's avatar Andy Regensky
Browse files

Save images with same size as defined sensor resolution

parent df92cdf4
...@@ -46,17 +46,18 @@ class FisheyeWidget(QWidget): ...@@ -46,17 +46,18 @@ class FisheyeWidget(QWidget):
@Slot() @Slot()
def saveImage(self): def saveImage(self):
filename = QFileDialog.getSaveFileName(self, "Save file", ".", ".png")[0] filename = QFileDialog.getSaveFileName(self, "Save file", ".", "Images (*.png)")[0]
if len(filename) == 0: if len(filename) == 0:
return return
if not filename.endswith(".png"): if not filename.endswith(".png"):
filename = filename + ".png" filename = filename + ".png"
height = 1080 width = self.viewModel.sensor_size_px[0]
scale = 1080 / self.size().height() height = self.viewModel.sensor_size_px[1]
width = scale * self.size().width() scaleW = width / self.size().width()
scaleH = height / self.size().height()
image = QImage(width, height, QImage.Format_RGB32) image = QImage(width, height, QImage.Format_RGB32)
painter = QPainter(image) painter = QPainter(image)
painter.scale(scale, scale) painter.scale(scaleW, scaleH)
self.render(painter, QPoint()) self.render(painter, QPoint())
painter.end() painter.end()
image.save(filename) image.save(filename)
...@@ -10,6 +10,7 @@ class PerspectiveWidget(QWidget): ...@@ -10,6 +10,7 @@ class PerspectiveWidget(QWidget):
def __init__(self, parent, viewModel: MainViewModel): def __init__(self, parent, viewModel: MainViewModel):
super().__init__(parent) super().__init__(parent)
self.viewModel = viewModel
self.perspectiveBackgroundWidget = PerspectiveBackgroundWidget(self, viewModel) self.perspectiveBackgroundWidget = PerspectiveBackgroundWidget(self, viewModel)
self.perspectiveBlockWidget = PerspectiveBlockWidget(self, viewModel) self.perspectiveBlockWidget = PerspectiveBlockWidget(self, viewModel)
self.show() self.show()
...@@ -33,17 +34,18 @@ class PerspectiveWidget(QWidget): ...@@ -33,17 +34,18 @@ class PerspectiveWidget(QWidget):
@Slot() @Slot()
def saveImage(self): def saveImage(self):
filename = QFileDialog.getSaveFileName(self, "Save file", ".", ".png")[0] filename = QFileDialog.getSaveFileName(self, "Save file", ".", "Images (*.png)")[0]
if len(filename) == 0: if len(filename) == 0:
return return
if not filename.endswith(".png"): if not filename.endswith(".png"):
filename = filename + ".png" filename = filename + ".png"
height = 1080 width = self.viewModel.sensor_size_px[0]
scale = 1080 / self.size().height() height = self.viewModel.sensor_size_px[1]
width = scale * self.size().width() scaleW = width / self.size().width()
scaleH = height / self.size().height()
image = QImage(width, height, QImage.Format_RGB32) image = QImage(width, height, QImage.Format_RGB32)
painter = QPainter(image) painter = QPainter(image)
painter.scale(scale, scale) painter.scale(scaleW, scaleH)
self.render(painter, QPoint()) self.render(painter, QPoint())
painter.end() painter.end()
image.save(filename) image.save(filename)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment