Commit feaa3c2a authored by Kriengsak's avatar Kriengsak

add save image for test

parent 8d90621e
...@@ -62,15 +62,26 @@ class Board(QWidget): ...@@ -62,15 +62,26 @@ class Board(QWidget):
cnt = 0 cnt = 0
maxf = 0 maxf = 0
for file in os.listdir(label): for file in os.listdir(label):
if file.endswith('.bmp'): if file.endswith('.png'):
cnt += 1 cnt += 1
tmpN = int(file[:-4:]) tmpN = int(file[:-4:])
maxf = max(maxf,tmpN) maxf = max(maxf,tmpN)
visibleImage.save('tmp.bmp') visibleImage.save('tmp.png')
pixmap = QPixmap('tmp.bmp').scaled(8,8) pixmap = QPixmap('tmp.png').scaled(16,16)
pixmap.save(label+'/'+str(max(cnt,maxf)+1)+'.bmp') pixmap.save(label+'/'+str(max(cnt,maxf)+1)+'.png')
QFile.remove('tmp.bmp') QFile.remove('tmp.png')
def saveImageTest(self):
import os
visibleImage = self.image
self.resizeImage(visibleImage,self.size())
if QDir('Test').exists() == False:
QDir().mkdir('Test')
visibleImage.save('tmp.png')
pixmap = QPixmap('tmp.png').scaled(16,16)
pixmap.save('Test/temp.png')
QFile.remove('tmp.png')
def paintEvent(self, event): def paintEvent(self, event):
painter = QPainter(self) painter = QPainter(self)
...@@ -117,4 +128,4 @@ class Board(QWidget): ...@@ -117,4 +128,4 @@ class Board(QWidget):
newImage.fill(qRgb(255,255,255)) newImage.fill(qRgb(255,255,255))
painter = QPainter(newImage) painter = QPainter(newImage)
painter.drawImage(QPoint(0,0), image) painter.drawImage(QPoint(0,0), image)
self.image = newImage self.image = newImage
\ No newline at end of file
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QAction, QApplication, QWidget,QGridLayout) from PyQt5.QtWidgets import (QAction, QApplication, QWidget,QGridLayout)
#from board import Board
#from clearButton import ClearButton
#from trainWidget import TrainWidget
#from testWidget import TestWidget
from ubuwidgets import (Button, ComboWidget, Board) from ubuwidgets import (Button, ComboWidget, Board)
class MainWindow(QWidget): class MainWindow(QWidget):
...@@ -45,4 +41,4 @@ if __name__ == '__main__': ...@@ -45,4 +41,4 @@ if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)
window = MainWindow() window = MainWindow()
window.show() window.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
\ No newline at end of file
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