Main Content

immagbox

Magnification box for image displayed in scroll panel

Description

Use theimmagboxfunction to add a magnification box to the same figure as an image contained in a scroll panel. A magnification box is an editable text box that contains the current magnification of the target image. When you enter a new value in the magnification box, the magnification of the target image changes. When the magnification of the target image changes for any reason, the magnification box updates the magnification value.

example

hbox= immagbox(hparent,himage)creates a magnification box for an image displayed in a scroll panel.himageis a handle to the target image in the scroll panel.hparentis a handle to the figure or uipanel object that will contain the magnification box. The function returnshbox, a handle to the magnification box.

Examples

collapse all

在图中显示图像。该示例在图形窗口中抑制了标准工具栏和Menubar,因为这些工具栏与滚动面板不起作用。

hFig =图('Toolbar','none','菜单栏','none');他= imshow('pears.png');

Create a scroll panel to contain the image.

hSP = imscrollpanel(hFig,hIm); set(hSP,'单位','normalized','位置',[0 .1 1 .9])

Figure contains an axes object and an object of type uipanel. The axes object contains an object of type image.

Add a magnification box to the figure. Set the position of the magnification box to the lower left corner of the figure.

hMagBox = immagbox(hFig,hIm); pos = get(hMagBox,'位置');set(hmagbox,'位置',[0 0 pos(3) pos(4)])

Figure contains an axes object and other objects of type uipanel, uicontrol. The axes object contains an object of type image.

Get the scroll panel API so that you can control the view programmatically.

apiSP = iptgetapi(hSP);

Set the magnification of the image to 200% by using the scroll panel API functionsetMagnification. Notice how the magnification box updates.

apiSP.setMagnification(2)

Figure contains an axes object and other objects of type uipanel, uicontrol. The axes object contains an object of type image.

Input Arguments

collapse all

Handle to a figure or uipanel object that contains the magnification box, specified as a handle.

句柄到目标图像,指定为手柄。该图像必须显示在创建的滚动面板中imscrollpanel.

Output Arguments

collapse all

Handle to magnification box, returned as a handle. A magnification box is a type of uipanel object.

More About

collapse all

Magnification Box API Structure

A magnification box contains a structure of function handles, called an API. You can use the functions in this API to manipulate the magnification box. To retrieve this structure, use theiptgetapi功能,如下示例。

api = iptgetapi(hbox)

This table lists the magnification box API functions, in the order they appear in the structure.

功能

Description

setMagnification

Set the magnification of the target image in units of screen pixels per image pixel.

mag = api.setMagnification(new_mag)

new_magis a scalar magnification factor.

Version History

Introduced before R2006a