Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Is it possible to place an image on a GUI button?

Subject: Is it possible to place an image on a GUI button?

From: Dimitri Shvorob

Date: 3 Nov, 2007 19:20:15

Message: 1 of 5

.. or am I limited to text? If yes, I would appreciate a
brief example.

Thanks!

Subject: Is it possible to place an image on a GUI button?

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 3 Nov, 2007 19:58:20

Message: 2 of 5

In article <fgihlf$7u2$1@fred.mathworks.com>,
Dimitri Shvorob <not.dimitri.shvorob@vanderbilt.edu> wrote:
>.. or am I limited to text? If yes, I would appreciate a
>brief example.

Try Doug Schwarz's "uibutton" FEX contribution.

--
   "Any sufficiently advanced bug is indistinguishable from a feature."
   -- Rich Kulawiec

Subject: Is it possible to place an image on a GUI button?

From: Yair Altman

Date: 3 Nov, 2007 19:58:38

Message: 3 of 5

"Dimitri Shvorob" <not.dimitri.shvorob@vanderbilt.edu> wrote
in message <fgihlf$7u2$1@fred.mathworks.com>...
> .. or am I limited to text? If yes, I would appreciate a
> brief example.
>
> Thanks!

Take a look at the Buttons submission on the File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=2378
or this one:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12033

Yair Altman
http://ymasoftware.com

Subject: Is it possible to place an image on a GUI button?

From: Lorenzo

Date: 3 Nov, 2007 20:04:06

Message: 4 of 5

"Dimitri Shvorob" <not.dimitri.shvorob@vanderbilt.edu> wrote in message
<fgihlf$7u2$1@fred.mathworks.com>...
> .. or am I limited to text? If yes, I would appreciate a
> brief example.
>
> Thanks!

Pushbuttons and toggle buttons have a 'cdata' property that takes a matrix of
colors to create an image. I remember using small bmp files to customize
buttons for an application I wrote. Here is a 4-line example:

>>[image_pic, image_map] =
imread('http://www.mathworks.com/matlabcentral/images/topnav/mlc_logo.
gif');

>>image_rgb = ind2rgb(image_pic,image_map);

>>button = uicontrol('style','pushbutton','position',[10 10 im_width+20
im_height+20])

>>set(button,'cdata',image_rgb)

The ind2rgb part is needed only because I'm starting from a .gif image; if it
was bmp, it would already be in the correct rgb format.

hth
Lorenzo


Subject: Is it possible to place an image on a GUI button?

From: Dimitri Shvorob

Date: 4 Nov, 2007 08:46:01

Message: 5 of 5

Many thanks to everyone who responded!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
imread Lorenzo 3 Nov, 2007 16:05:08
image Lorenzo 3 Nov, 2007 16:05:08
gui Lorenzo 3 Nov, 2007 16:05:08
buttons Lorenzo 3 Nov, 2007 16:05:08
gui Dimitri Shvorob 3 Nov, 2007 15:25:04
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics