當前位置: 首頁>>代碼示例>>Python>>正文


Python wx.BITMAP_TYPE_JPEG屬性代碼示例

本文整理匯總了Python中wx.BITMAP_TYPE_JPEG屬性的典型用法代碼示例。如果您正苦於以下問題:Python wx.BITMAP_TYPE_JPEG屬性的具體用法?Python wx.BITMAP_TYPE_JPEG怎麽用?Python wx.BITMAP_TYPE_JPEG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在wx的用法示例。


在下文中一共展示了wx.BITMAP_TYPE_JPEG屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: saveImage

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BITMAP_TYPE_JPEG [as 別名]
def saveImage(self, bmp, filename, folder, prefix, format='jpg'):
        # convert
        img = bmp.ConvertToImage()

        # save
        if format == 'gif':
            fileName = os.path.join(folder,"%s%s.gif" % (prefix, filename))
            img.SaveFile(fileName, wx.BITMAP_TYPE_GIF)

        elif format == 'png':
            fileName = os.path.join(folder,"%s%s.png" % (prefix, filename))
            img.SaveFile(fileName, wx.BITMAP_TYPE_PNG)

        else:
            fileName = os.path.join(folder,"%s%s.jpg" % (prefix, filename))
            img.SaveFile(fileName, wx.BITMAP_TYPE_JPEG) 
開發者ID:collingreen,項目名稱:chronolapse,代碼行數:18,代碼來源:chronolapse.py

示例2: print_jpeg

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BITMAP_TYPE_JPEG [as 別名]
def print_jpeg(self, filename, *args, **kwargs):
            return self._print_image(filename, wx.BITMAP_TYPE_JPEG, *args, **kwargs) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:4,代碼來源:backend_wx.py

示例3: print_jpeg

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BITMAP_TYPE_JPEG [as 別名]
def print_jpeg(self, filename, *args, **kwargs):
            return self._print_image(filename, wx.BITMAP_TYPE_JPEG,
                                     *args, **kwargs) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:5,代碼來源:backend_wx.py

示例4: _print_image

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BITMAP_TYPE_JPEG [as 別名]
def _print_image(self, filename, filetype, *args, **kwargs):
        origBitmap   = self.bitmap

        l,b,width,height = self.figure.bbox.bounds
        width = int(math.ceil(width))
        height = int(math.ceil(height))

        self.bitmap = wx.EmptyBitmap(width, height)
        renderer = RendererWx(self.bitmap, self.figure.dpi)

        gc = renderer.new_gc()

        self.figure.draw(renderer)

        # image is the object that we call SaveFile on.
        image = self.bitmap
        # set the JPEG quality appropriately.  Unfortunately, it is only possible
        # to set the quality on a wx.Image object.  So if we are saving a JPEG,
        # convert the wx.Bitmap to a wx.Image, and set the quality.
        if filetype == wx.BITMAP_TYPE_JPEG:
           jpeg_quality = kwargs.get('quality',rcParams['savefig.jpeg_quality'])
           image = self.bitmap.ConvertToImage()
           image.SetOption(wx.IMAGE_OPTION_QUALITY,str(jpeg_quality))

        # Now that we have rendered into the bitmap, save it
        # to the appropriate file type and clean up
        if is_string_like(filename):
            if not image.SaveFile(filename, filetype):
                DEBUG_MSG('print_figure() file save error', 4, self)
                raise RuntimeError('Could not save figure to %s\n' % (filename))
        elif is_writable_file_like(filename):
            if not isinstance(image,wx.Image):
               image = image.ConvertToImage()
            if not image.SaveStream(filename, filetype):
                DEBUG_MSG('print_figure() file save error', 4, self)
                raise RuntimeError('Could not save figure to %s\n' % (filename))

        # Restore everything to normal
        self.bitmap = origBitmap

        # Note: draw is required here since bits of state about the
        # last renderer are strewn about the artist draw methods.  Do
        # not remove the draw without first verifying that these have
        # been cleaned up.  The artist contains() methods will fail
        # otherwise.
        if self._isDrawn:
            self.draw()
        self.Refresh() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:50,代碼來源:backend_wx.py

示例5: _print_image

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BITMAP_TYPE_JPEG [as 別名]
def _print_image(self, filename, filetype, *args, **kwargs):
        origBitmap = self.bitmap

        l, b, width, height = self.figure.bbox.bounds
        width = math.ceil(width)
        height = math.ceil(height)

        self.bitmap = wx.Bitmap(width, height)

        renderer = RendererWx(self.bitmap, self.figure.dpi)

        gc = renderer.new_gc()

        self.figure.draw(renderer)

        # image is the object that we call SaveFile on.
        image = self.bitmap
        # set the JPEG quality appropriately.  Unfortunately, it is only
        # possible to set the quality on a wx.Image object.  So if we
        # are saving a JPEG, convert the wx.Bitmap to a wx.Image,
        # and set the quality.
        if filetype == wx.BITMAP_TYPE_JPEG:
            jpeg_quality = kwargs.get('quality',
                                      rcParams['savefig.jpeg_quality'])
            image = self.bitmap.ConvertToImage()
            image.SetOption(wx.IMAGE_OPTION_QUALITY, str(jpeg_quality))

        # Now that we have rendered into the bitmap, save it to the appropriate
        # file type and clean up.
        if isinstance(filename, str):
            if not image.SaveFile(filename, filetype):
                raise RuntimeError(f'Could not save figure to {filename}')
        elif cbook.is_writable_file_like(filename):
            if not isinstance(image, wx.Image):
                image = image.ConvertToImage()
            if not image.SaveStream(filename, filetype):
                raise RuntimeError(f'Could not save figure to {filename}')

        # Restore everything to normal
        self.bitmap = origBitmap

        # Note: draw is required here since bits of state about the
        # last renderer are strewn about the artist draw methods.  Do
        # not remove the draw without first verifying that these have
        # been cleaned up.  The artist contains() methods will fail
        # otherwise.
        if self._isDrawn:
            self.draw()
        self.Refresh()


########################################################################
#
# The following functions and classes are for pylab compatibility
# mode (matplotlib.pylab) and implement figure managers, etc...
#
######################################################################## 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:59,代碼來源:backend_wx.py


注:本文中的wx.BITMAP_TYPE_JPEG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。