프로젝트

일반

사용자정보

개정판 4502efac

ID4502efac3de3cbb3a3fe9c40842eaa63951027c0
상위 206eb105
하위 dc3bb0e4

백흠경이(가) 약 5년 전에 추가함

issue #1059: 화면을 이미지 파일로 저장하는 기능 추가

Change-Id: I26cd2149f986246976545098c752e0589fc31918

차이점 보기:

HYTOS/HYTOS/MainWindow.py
425 425

  
426 426
    def open_selected_drawing(self, item):
427 427
        """ open selected drawing """
428
        path = item.text(2)
429
        if os.path.exists(path):
430
            self.open_drawing(path)
428
        try:
429
            path = item.text(2)
430
            if os.path.exists(path):
431
                self.open_drawing(path)
431 432

  
433
        except Exception as ex:
434
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
435
                                                           sys.exc_info()[-1].tb_lineno)
436
            self.addMessage.emit(MessageType.Error, message)
432 437
    '''
433 438
        @brief      action save click event
434 439
        @author     kyouho
HYTOS/HYTOS/QtImageViewer.py
604 604
        items = [item for item in self.scene.items() if hasattr(item, 'uid') and str(item.uid) == str(uid)]
605 605
        return items[0] if items else None
606 606

  
607
    def save_as_image(self, file_path):
608
        """ save scene as given file """
609
        rect = self.sceneRect()
610
        size = QSize(rect.width(), rect.height())
611
        image = QImage(size, QImage.Format_ARGB32_Premultiplied)
612
        painter = QPainter(image)
613

  
614
        # render the scene
615
        self.scene.render(painter)
616
        painter.end()
617

  
618
        # save the image to a given file
619
        image.save(file_path)
620

  
607 621
if __name__ == '__main__':
608 622
    import sys
609 623
    try:

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)