To use png images in Matlab UIControl, you can use the following steps:
Use imread()
function to read the png file into a matrix.
Use uicontrol()
function to create a UIControl and set its properties including the CData
property.
Set the CData
property to the matrix that you read in step 1.
Here is an example code snippet:
main.m258 chars10 lines
In this example, we create a push button by calling the uicontrol()
function and specifying its style as pushbutton
. We also set the CData
property of the button to the image matrix that we read using the imread()
function.
Once you run this code, a figure window will pop up with a push button having the specified png image on it.
gistlibby LogSnag