我正在使用Matlab编写一个GUI,用于一项实验,参与测试的人将查看一系列图像,并在每个图像后响应其评分。
我希望窗口始终保持最大化。图像将显示几秒钟,然后消失,出现评分滑块。接下来,会隐藏滑块,新的图像将出现,以此类推...
到目前为止,我开始时使用最大化窗口的设置很好,但在加载并显示图像(使用imshow或image命令)后,窗口会调整大小并适应图像,而不是保持最大化。如果我再次最大化窗口,它会导致一个明显的闪烁,因为窗口框架先被最大化,然后调整大小,再次最大化 - 这是我想避免的闪烁。
如何保持窗口最大化,并以1:1的比例显示图像(不缩放或调整大小以适应最大化的窗口)?
我知道PsychToolbox,但它似乎没有创建滑块的命令(我将用于评分),而且我不想从头开始做这些。我还研究了来自Matlab文件交换的windowAPI,但仍未找到解决方案。
下面是我目前所拥有的内容的示例(在Windows 7 64位上使用Matlab R2013a):
感谢您的来信,Christian。
我希望窗口始终保持最大化。图像将显示几秒钟,然后消失,出现评分滑块。接下来,会隐藏滑块,新的图像将出现,以此类推...
到目前为止,我开始时使用最大化窗口的设置很好,但在加载并显示图像(使用imshow或image命令)后,窗口会调整大小并适应图像,而不是保持最大化。如果我再次最大化窗口,它会导致一个明显的闪烁,因为窗口框架先被最大化,然后调整大小,再次最大化 - 这是我想避免的闪烁。
如何保持窗口最大化,并以1:1的比例显示图像(不缩放或调整大小以适应最大化的窗口)?
我知道PsychToolbox,但它似乎没有创建滑块的命令(我将用于评分),而且我不想从头开始做这些。我还研究了来自Matlab文件交换的windowAPI,但仍未找到解决方案。
下面是我目前所拥有的内容的示例(在Windows 7 64位上使用Matlab R2013a):
screenSize = get(0,'screensize');
screenWidth = screenSize(3);
screenHeight = screenSize(4);
% Create figure window, keeping it invisible while adding UI controls, etc.
hFig = figure('Name','APP',...
'Numbertitle','off',...
'Position', [0 0 screenWidth screenHeight],...
'WindowStyle','modal',...
'Color',[0.5 0.5 0.5],...
'Toolbar','none',...
'Visible','off');
% Make the figure window visible
set(hFig,'Visible','on');
% Maximize the figure window, using WindowAPI
WindowAPI(hFig, 'Position', 'work');
% Pause (in the full version of this script, this would instead be
% a part where some UI elements are shown and later hidden...
pause(1.0);
% Read image file
img = imread('someImage.png');
% Create handle for imshow, and hiding the image for now.
% This is where Matlab decides to modify the figure window,
% so it fits the image rather than staying maximized.
hImshow = imshow(img);
set(hImshow,'Visible','off');
% Show the image
set(hImshow,'Visible','on');
感谢您的来信,Christian。
axOffset = (fpos(3:4)-[size(img,2) size(img,1)])/2;
再次感谢! - ctp