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:

gui(2), image(2), buttons, imread

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
image ous 2k 5 Dec, 2009 15:54:29
image Lorenzo 3 Nov, 2007 16:05:08
buttons Lorenzo 3 Nov, 2007 16:05:08
imread Lorenzo 3 Nov, 2007 16:05:08
gui Lorenzo 3 Nov, 2007 16:05:08
gui Dimitri Shvorob 3 Nov, 2007 15:25:04
rssFeed for this Thread

Contact us at files@mathworks.com