- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在 Matlab 中编写一个 GUI 用于实验,测试参与者将查看一系列图像,并在每张图像后回复对该图像的评分。
我想一直保持窗口最大化。图像将显示几秒钟,然后移除,一些 slider 将出现用于评级。接下来, slider 将被隐藏,并出现一个新图像,等等......
到目前为止,我从最大化图形窗口开始就很好,直到我使用 imshow 或图像命令加载图像并显示它,这会导致图形窗口调整大小并适合图像,而不是保持最大化。如果我然后再次最大化图形窗口,它会导致窗口框架明显闪烁,首先最大化,然后调整大小,然后再次最大化 - 我想避免的闪烁。
如何保持窗口最大化,并以 1:1 的比例显示图像(不缩放或调整大小以适应最大化的窗口)?
我知道 PsychToolbox,但它似乎没有创建 slider 的命令(我会用它来进行评级),我不想从头开始做这些。我还研究了来自 Matlab File Exchange 的 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');
谢谢,基督徒
最佳答案
尝试将 'InitialMagnification'
参数与 'fit'
选项值一起用于 imshow
:
hImshow = imshow(img,'InitialMagnification','fit')
You can also specify the text string 'fit' as the initial magnification value. In this case, imshow scales the image to fit the current size of the figure window
另见 this section of the imshow
docs关于 'InitialMagnification'
。因此,这应该使您的图形窗口保持相同大小。
这将解决丢失窗口最大化的问题。
要在屏幕上以 1 像素到 1 点的比例显示图像,您可以为图像创建一个正确大小的轴,并显示到其中:
fpos = get(hFig,'Position')
axOffset = (fpos(3:4)-[size(img,2) size(img,1)])/2;
ha = axes('Parent',hFig,'Units','pixels',...
'Position',[axOffset size(img,2) size(img,1)]);
hImshow = imshow(img,'Parent',ha);
请注意,没有必要指定放大倍率,因为“如果您指定轴位置(使用子图或轴),imshow
会忽略您可能已指定的任何初始放大倍率并默认为 ” fit'
behavior”,从而适合由 'Parent'
指定的轴。
关于matlab - 显示新图像时如何使 Matlab 图形窗口最大化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19989565/
给定一个包含 n 个非负整数的数组:A1、A2、...、AN。如何找到一对整数 Au, Av (1 ≤ u ans) { ans=arr[i] & arr[j
有人知道这段代码的正确解决方案吗? BOOL maximized = [myWindow isMaximized]; 最佳答案 也许看看 isZoomed 关于cocoa - NSWindow 最大化
当前有一个 MySQL 数据库,但遇到 MySQL 以 600% CPU 使用率运行的问题。 规范: 2.3 GHz Intel Xeon® E5-2686 v4 (Broadwell) 处理器或 2
我已将 Skype 配置为在 Windows 启动时最小化启动。 现在我需要通过全屏应用程序按钮中的一个按钮将 Skype 置于最前面。我有这段代码: For Each p As Proces
我已经有一段时间没有做任何生疏的程序了。我正在研究代码以最大化和最小化其他应用程序。所以我找到了一些基本的东西,这就是我所拥有的,对原来的东西稍作修改。它希望我生成一些我所做的 FindWindow
我有一个 Windows CE 应用程序,它记录移动设备的击键。有一个用于初始化录制功能的按钮,它通过调用强制主窗口最小化: ShowWindow (hWnd, SW_MINIMIZE); 在最小化窗
我想显示一个占据尽可能多屏幕空间的对话框。 所以,这是一个示例: AlertDialog dialog = new AlertDialog.Builder(ctx)......create(); Wi
对Wndows用户来说,最小化/最大化/关闭按钮放在系统窗口的右上角是肯定的。而大多数朋友都是成为Wndows用户之后才成为Ubuntu用户的,因此Ubuntu程序窗口中将这些按键放在左上角使用起来
1.Ctrl+Alt+T调出终端 2.首先安装gconf-editor: sudo apt-get install gconf-editor 会提示叫你安装 gconf-editor 安装完成
Width最大化窗口时,屏幕的属性似乎没有更新到完全最大化的宽度。如果我调整它的大小,一切正常,但在最大化时就不行。 我的代码如下: private void Window_SizeChanged(o
我正在这个 fiddle 中使用指令和 = 绑定(bind)。我收到以下错误: Uncaught Error: 10 $digest() iterations reached. Aborting! W
是否有任何快捷方式可以最大化您在 Eclipse 中使用的选项卡?假设我正在处理代码的一部分,并且我想最大化选项卡而不是使用鼠标双击它,有人知道一种方法吗? 最佳答案 CtrlM 将最大化/恢复编辑器
在 Glassdoor 评论中遇到这个问题,觉得很有趣。 Given an integer consisting of 4 digits, we need to maximize it in 24 h
在 VB6 中,我创建了一个带有一些文本框、列表框和命令按钮的表单。我使用类似 的方法设置所有这些控件的 X-Y 位置 control2.Top = form.Height * 0.50 'set
到处都有人告诉我使用这个: frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 但问题是我的 JMenuBar 时断时续地消失(发生在我身上的奇怪错误),并且
我有一个 JDesktopPane 和一个 JInternalFrame。我希望 JInternalFrame 在创建后自动最大化。如何对“最大化窗口”事件进行硬编码? 最佳答案 使用JInterna
这个问题已经有答案了: JFrame doesn't take the actual screen size (2 个回答) 已关闭 3 年前。 我想最大化我的 JFrame,就像按下“关闭”旁边的按
我正在使用 vim 和 python 编程,并使用 tpope's vim-dispatch通过运行当前文件 :Dispatch python main.py 程序的打印输出被定向到quickfix窗
假设我们有一个名为 total 的 NSDecimal 常量,它包含 3.33333333 除以 10/3 的值。 10 和 3 都是NSDecimalNumber。我们希望 Swift 中的 NSD
有谁知道如何在发生特定操作后最大化 JFrame?我将在下面发布我的代码,我是一个不评论我的代码的恶魔(我会在某个时候这样做)但它应该是相当 self 解释的。我试图做的是在从菜单中选择选项后使框架最
我是一名优秀的程序员,十分优秀!