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


Python wx.Image方法代碼示例

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


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

示例1: create_thumb_bmp

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def create_thumb_bmp(self, filename):
        wximg = wx.Image(filename, type=wx.BITMAP_TYPE_ANY)
        imgsize = wximg.GetSize()
        w2h_ratio = imgsize[0]/imgsize[1]
        if w2h_ratio > 1:
            target_w = self.tsize[0]
            target_h = target_w/w2h_ratio
            pos = (0, round((target_w - target_h)/2))
        else:
            target_h = self.tsize[1]
            target_w = target_h*w2h_ratio
            pos = (round((target_h - target_w)/2), 0)
        bmp = wximg.Scale(target_w,
                          target_h,
                          quality=wx.IMAGE_QUALITY_BOX_AVERAGE
                         ).Resize(self.tsize,
                                  pos
                                 ).ConvertToBitmap()
        return bmp

    #
    # BUTTON methods
    # 
開發者ID:hhannine,項目名稱:superpaper,代碼行數:25,代碼來源:configuration_dialogs.py

示例2: onChooseTestImage

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def onChooseTestImage(self, event):
        """Open a file dialog to choose a test image."""
        with wx.FileDialog(self, "Choose a test image",
                           wildcard=("Image files (*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.webp)"
                                     "|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.webp"),
                           defaultDir=self.frame.defdir,
                           style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as file_dialog:

            if file_dialog.ShowModal() == wx.ID_CANCEL:
                return     # the user changed their mind

            # Proceed loading the file chosen by the user
            self.test_image = file_dialog.GetPath()
            self.tc_testimage.SetValue(
                os.path.basename(self.test_image)
            )
        return 
開發者ID:hhannine,項目名稱:superpaper,代碼行數:19,代碼來源:configuration_dialogs.py

示例3: create_thumb_bmp

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def create_thumb_bmp(self, filename):
        wximg = wx.Image(filename, type=wx.BITMAP_TYPE_ANY)
        imgsize = wximg.GetSize()
        w2h_ratio = imgsize[0]/imgsize[1]
        if w2h_ratio > 1:
            target_w = self.tsize[0]
            target_h = target_w/w2h_ratio
            pos = (0, round((target_w - target_h)/2))
        else:
            target_h = self.tsize[1]
            target_w = target_h*w2h_ratio
            pos = (round((target_h - target_w)/2), 0)
        bmp = wximg.Scale(
            target_w,
            target_h,
            quality=wx.IMAGE_QUALITY_BOX_AVERAGE
            ).Resize(
                self.tsize, pos
            ).ConvertToBitmap()
        return bmp 
開發者ID:hhannine,項目名稱:superpaper,代碼行數:22,代碼來源:gui.py

示例4: resize_and_bitmap

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def resize_and_bitmap(self, fname, size, enhance_color=False):
        """Take filename of an image and resize and center crop it to size."""
        try:
            pil = resize_to_fill(Image.open(fname), size, quality="fast")
        except UnidentifiedImageError:
            msg = ("Opening image '%s' failed with PIL.UnidentifiedImageError."
                   "It could be corrupted or is of foreign type.") % fname
            sp_logging.G_LOGGER.info(msg)
            # show_message_dialog(msg)
            black_bmp = wx.Bitmap.FromRGBA(size[0], size[1], red=0, green=0, blue=0, alpha=255)
            if enhance_color:
                return (black_bmp, black_bmp)
            return black_bmp
        img = wx.Image(pil.size[0], pil.size[1])
        img.SetData(pil.convert("RGB").tobytes())
        if enhance_color:
            converter = ImageEnhance.Color(pil)
            pilenh_bw = converter.enhance(0.25)
            brightns = ImageEnhance.Brightness(pilenh_bw)
            pilenh = brightns.enhance(0.45)
            imgenh = wx.Image(pil.size[0], pil.size[1])
            imgenh.SetData(pilenh.convert("RGB").tobytes())
            return (img.ConvertToBitmap(), imgenh.ConvertToBitmap())
        return img.ConvertToBitmap() 
開發者ID:hhannine,項目名稱:superpaper,代碼行數:26,代碼來源:gui.py

示例5: on_button_run

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def on_button_run(self, event):

        # Build and run SCT command
        fname_input = self.hbox_filein.textctrl.GetValue()
        contrast = self.rbox_contrast.GetStringSelection()
        base_name = os.path.basename(fname_input)
        fname, fext = base_name.split(os.extsep, 1)
        fname_out = "{}_seg.{}".format(fname, fext)
        cmd_line = "sct_propseg -i {} -c {}".format(fname_input, contrast)
        self.call_sct_command(cmd_line)

        # Add output to the list of overlay
        image = Image(fname_out)  # <class 'fsl.data.image.Image'>
        overlayList.append(image)
        opts = displayCtx.getOpts(image)
        opts.cmap = 'red' 
開發者ID:neuropoly,項目名稱:spinalcordtoolbox,代碼行數:18,代碼來源:sct_plugin.py

示例6: OnSelect

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def OnSelect(self, event):
        wildcard = "image source(*.jpg)|*.jpg|" \
                   "Compile Python(*.pyc)|*.pyc|" \
                   "All file(*.*)|*.*"
        dialog = wx.FileDialog(None, "Choose a file", os.getcwd(),
                               "", wildcard, wx.ID_OPEN)
        if dialog.ShowModal() == wx.ID_OK:
            print(dialog.GetPath())
            img = Image.open(dialog.GetPath())
            imag = img.resize([64, 64])
            image = np.array(imag)
            result = evaluate_one_image(image)
            result_text = wx.StaticText(self.pnl, label=result, pos=(320, 0))
            font = result_text.GetFont()
            font.PointSize += 8
            result_text.SetFont(font)
            self.initimage(name= dialog.GetPath())

    # 生成圖片控件 
開發者ID:chonepieceyb,項目名稱:reading-frustum-pointnets-code,代碼行數:21,代碼來源:gui.py

示例7: graph_caps

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def graph_caps(self, cap_files, graphdir):
        OS = "linux"
        if len(cap_files) > 1:
            print("make caps graph")
            if OS == "linux":
                print("Yay linux")
                os.system("../visualisation/caps_graph.py caps="+capsdir+" out="+graphdir)
            elif OS == 'win':
                print("oh, windows, i prefer linux but no worries...")
                os.system("python ../visualisation/caps_graph.py caps="+capsdir+" out="+graphdir)
        else:
            print("skipping graphing caps - disabled or no caps to make graphs with")
        if os.path.exists(graphdir+'caps_filesize_graph.png'):
            cap_size_graph_path = wx.Image(graphdir+'caps_filesize_graph.png', wx.BITMAP_TYPE_ANY)
            return cap_size_graph_path
        else:
            print("NOT ENOUGH CAPS GRAPH SO USING BLANK THUMB")
            blankimg = wx.EmptyImage(width=100, height=100, clear=True)
            return blankimg 
開發者ID:Pragmatismo,項目名稱:Pigrow,代碼行數:21,代碼來源:make_timelapse.py

示例8: _Draw

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None):
        XY = WorldToPixel(self.XY)
        H = ScaleWorldToPixel(self.Height)[0]
        W = H * (self.bmpWidth / self.bmpHeight)
        if (self.ScaledBitmap is None) or (H != self.ScaledHeight) :
            self.ScaledHeight = H
            Img = self.Image.Scale(W, H)
            self.ScaledBitmap = wx.Bitmap(Img)

        XY = self.ShiftFun(XY[0], XY[1], W, H)
        dc.DrawBitmap(self.ScaledBitmap, XY, True)
        if HTdc and self.HitAble:
            HTdc.SetPen(self.HitPen)
            HTdc.SetBrush(self.HitBrush)
            HTdc.DrawRectangle(XY, (W, H) ) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:17,代碼來源:FCObjects.py

示例9: _DrawEntireBitmap

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def _DrawEntireBitmap(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc):
        """
        this is pretty much the old code

        Scales and Draws the entire bitmap.

        """
        XY = WorldToPixel(self.XY)
        H = ScaleWorldToPixel(self.Height)[0]
        W = H * (self.bmpWidth / self.bmpHeight)
        if (self.ScaledBitmap is None) or (self.ScaledBitmap[0] != (0, 0, self.bmpWidth, self.bmpHeight, W, H) ):
        #if True: #fixme: (self.ScaledBitmap is None) or (H != self.ScaledHeight) :
            self.ScaledHeight = H
            #print("Scaling to:", W, H)
            Img = self.Image.Scale(W, H)
            bmp = wx.Bitmap(Img)
            self.ScaledBitmap = ((0, 0, self.bmpWidth, self.bmpHeight , W, H), bmp)# this defines the cached bitmap
        else:
            #print("Using Cached bitmap")
            bmp = self.ScaledBitmap[1]
        XY = self.ShiftFun(XY[0], XY[1], W, H)
        dc.DrawBitmap(bmp, XY, True)
        if HTdc and self.HitAble:
            HTdc.SetPen(self.HitPen)
            HTdc.SetBrush(self.HitBrush)
            HTdc.DrawRectangle(XY, (W, H) ) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:28,代碼來源:FCObjects.py

示例10: EmptyImage

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def EmptyImage(width=0, height=0, clear=True):
    """
    A compatibility wrapper for the wx.Image(width, height) constructor
    """
    return Image(width, height, clear) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:7,代碼來源:core.py

示例11: ImageFromStream

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def ImageFromStream(stream, type=BITMAP_TYPE_ANY, index=-1):
    """
    Load an image from a stream (file-like object)
    """
    return wx.Image(stream, type, index) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:7,代碼來源:core.py

示例12: ImageFromData

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def ImageFromData(width, height, data):
    """
    Compatibility wrapper for creating an image from RGB data
    """
    return Image(width, height, data) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:7,代碼來源:core.py

示例13: ImageFromDataWithAlpha

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def ImageFromDataWithAlpha(width, height, data, alpha):
    """
    Compatibility wrapper for creating an image from RGB and Alpha data
    """
    return Image(width, height, data, alpha) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:7,代碼來源:core.py

示例14: ImageFromBuffer

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None):
    """
    Creates a :class:`Image` from the data in `dataBuffer`.  The `dataBuffer`
    parameter must be a Python object that implements the buffer interface,
    such as a string, array, etc.  The `dataBuffer` object is expected to
    contain a series of RGB bytes and be width*height*3 bytes long.  A buffer
    object can optionally be supplied for the image's alpha channel data, and
    it is expected to be width*height bytes long.
    
    The :class:`Image` will be created with its data and alpha pointers initialized
    to the memory address pointed to by the buffer objects, thus saving the
    time needed to copy the image data from the buffer object to the :class:`Image`.
    While this has advantages, it also has the shoot-yourself-in-the-foot
    risks associated with sharing a C pointer between two objects.
    
    To help alleviate the risk a reference to the data and alpha buffer
    objects are kept with the :class:`Image`, so that they won't get deleted until
    after the wx.Image is deleted.  However please be aware that it is not
    guaranteed that an object won't move its memory buffer to a new location
    when it needs to resize its contents.  If that happens then the :class:`Image`
    will end up referring to an invalid memory location and could cause the
    application to crash.  Therefore care should be taken to not manipulate
    the objects used for the data and alpha buffers in a way that would cause
    them to change size.
    """
    img = Image(width, height)
    img.SetDataBuffer(dataBuffer)
    if alphaBuffer:
        img.SetAlphaBuffer(alphaBuffer)
    img._buffer = dataBuffer
    img._alpha = alphaBuffer
    return img 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:34,代碼來源:core.py

示例15: BitmapFromImage

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import Image [as 別名]
def BitmapFromImage(image):
    """
    A compatibility wrapper for the wx.Bitmap(wx.Image) constructor
    """
    return Bitmap(image) 
開發者ID:dougthor42,項目名稱:wafer_map,代碼行數:7,代碼來源:core.py


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