Ejemplo n.º 1
0
 def take_thumbnail(self, button):
     output_path = None
     if self.standalone:
         current_file = swidgets.brows_file(
             'find the thumbnail(image) file', resource.getImageFormats())
         if not current_file:
             return
         output_path = os.path.join(
             tempfile.gettempdir(),
             'thumbnail_%s.png' % resource.getCurrentDateKey())
         output_path = swidgets.image_resize(current_file, output_path, 768,
                                             540)
     else:
         from studio_usd_pipe.api import studioMaya
         smaya = studioMaya.Maya()
         output_path, w, h = smaya.vieport_snapshot(
             output_path=None,
             width=768,
             height=540,
         )
     if not os.path.isfile(output_path):
         return
     qsize = button.minimumSize()
     swidgets.image_to_button(button,
                              qsize.width(),
                              qsize.height(),
                              path=output_path)
     self.button_thumbnail.setToolTip(output_path)
Ejemplo n.º 2
0
 def load_image_file(self):
     current_file = swidgets.brows_file(
         'find the thumbnail(image) file', resource.getImageFormats())        
     if not current_file:
         return
     os.environ['BROWS_PATH'] = os.path.dirname(current_file)
     output_path = os.path.join(
         tempfile.gettempdir(),
         'thumbnail_%s.png' % resource.getCurrentDateKey())        
     output_path = swidgets.image_resize(current_file, output_path, 768, 540)
     size = self.button_thumbnail.minimumSize()
     swidgets.image_to_button(
         self.button_thumbnail, size.width(), size.height(), path=output_path)
     self.button_thumbnail.setToolTip(output_path)        
Ejemplo n.º 3
0
 def vieport_snapshot(self, output_path=None, width=2048, height=2048):
     OpenMaya.MGlobal.clearSelectionList()
     m3d_view = OpenMayaUI.M3dView.active3dView()
     if not m3d_view.isVisible():
         OpenMaya.MGlobal.displayWarning('Active 3d View not visible!...')
         return
     m3d_view.refresh(True, True, True)
     m_image = OpenMaya.MImage()
     m3d_view.readColorBuffer(m_image, True)
     if not output_path:
         output_path = os.path.join(
             tempfile.gettempdir(),
             'studio_pipe_temp_%s.png' % resource.getCurrentDateKey())
     format = os.path.splitext(output_path)[-1].replace('.', '')
     if not format:
         format = 'png'
     m_image.writeToFileWithDepth(output_path, format, False)
     swidgets.image_resize(output_path,
                           output_path,
                           width=width,
                           height=width)
     return output_path, width, height