Graphics on pushbuttons for gUI's

Hi, Im trying to put an image onto a push button. However, I seem to be missing something.
Heres my attempt.
Al=imread('LeftArrow.png');
a(:,:,1) = Al;
a(:,:,2) = Al;
a(:,:,3) = Al;
set(handles.pushbuttonLEFT,'CData',a)

 Accepted Answer

Your png file is RGB, so Al is already 3 dimensional. When you try to assign the 3 dimensional array to the two dimensional array a(:,:,1) you are going to fail.

3 Comments

Oh yes thank you, the following now works.
Al=imread('LeftArrow.png');
set(handles.pushbuttonLEFT,'CData',Al)
But it swamps the push button. Does matlab allow the image to be made smaller, so you can still see the 3D effect of the pushbutton? Thanks
If you have the appropriate toolbox you can imresize() what you send into CData.
Thankyou

Sign in to comment.

More Answers (0)

Categories

Asked:

on 9 Oct 2015

Commented:

on 9 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!