当前位置: 首页>>代码示例>>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;未经允许,请勿转载。