.jpg as a background on gui
2 次查看(过去 30 天)
显示 更早的评论
I have a code that creates a projectile motion. I'm looking to make the background a .jpg file instead of colors that I currently use. Help is much appreciated. This is our current background.
backgroundX = [0 1 2 3 4 5 6 7 8 9 10 0];
backgroundY = [0 4 2 7 5 8 3 4 2 5 0 0];
backgroundX1 = [0 .75 1.5 2 2.8 3.5 4 4.666667 5.2 6 6.5 7.25 8,...
8.66667 9.2 10 0];
backgroundY1 = [0 3 3 2 6 6 5 7 7 3 3.5 3.5 2 4 4 0 0];
backgroundX2 = [0 0 1 2 3 4 5 6 7 8 9 10 10 0];
backgroundY2 = [10 0 4 2 7 5 8 3 4 2 5 0 10 10];
fill(330*backgroundX,200*backgroundY,'PhilSkyline.jpg')
fill(330*backgroundX1,200*backgroundY1,[0 .65 0])
fill(330*backgroundX2,200*backgroundY2,[.3 .7 1])
axis([0 3300 0 2000])
0 个评论
回答(2 个)
Giorgos Papakonstantinou
2015-3-2
编辑:Giorgos Papakonstantinou
2015-3-2
You can create a figure and remove the MenuBar. In this figure you can display your image, whose parent is an axis. You can set the axis position to occupy the full dimension of your figure.
i.e.
fig = figure('MenuBar', 'none');
IM = imread('peppers.png');
h = image(IM);
set(get(h, 'parent'),'XTick', [], 'YTick', [], 'position' , [0 0 1 1])
2 个评论
Giorgos Papakonstantinou
2015-3-3
The limits of your axis are the same size of your image. Therefore when you invoke the|axis| command you change the limits of the axis: [xmin xmax ymin ymax]. You set them [0 2000 0 2000].
Is this size of your image? (2000 x 2000).
Moreover, when you issue axis equal you set the aspect ratio so that the data units are the same in every direction. As a result your image does not fill the whole figure when you resize the figure.
Image Analyst
2015-3-3
How about this from the Mathworks Support Team?
2 个评论
Image Analyst
2015-3-3
I don't know. I've never tried it but I doubt it. I think fill just fills with a uniform color.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!