【问题标题】:Load image called with pushbutton to the pushbutton's background [closed]将使用按钮调用的图像加载到按钮的背景[关闭]
【发布时间】:2017-12-19 09:45:21
【问题描述】:

在回答之前,请记住我是 Matlab 的新手。

大家好,我正在尝试在单击按钮时在按钮上加载图片。

一旦我将 .jpg 图像加载到按钮上,图像非常大,在按钮后面,设置为背景图像;如何调整它的大小以使其适合按钮(如果可能,最好设置为按钮的背景图像)?

【问题讨论】:

    标签: image matlab button background


    【解决方案1】:

    您可以使用imresize 使图像适合您的按钮大小。

    例子:

    buttonWidth  = 100; %in Pixels
    buttonHeight = 100;
    imPad        = 10;  %A little bit of padding
    
    imData = imread('yourImage.jpg');  %Read your image
    imSmall= imresize(imData , [buttonWidth   buttonHeight]-imPad); %Resize it.
    
    % Place it on the button
    h=uicontrol('style','pushbutton', 'units','pixels',...
                'position',[50 50 buttonWidth buttonHeight],...
                'cdata',imSmall)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-06
      • 2019-11-11
      • 1970-01-01
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多