Matlab - how to draw pixels on a black full screen?

天大地大妈咪最大 提交于 2019-12-01 03:34:13

问题


I want matlab to show me a full screen, all black, and to be able to set pixels on it.

Is it even possible?


回答1:


You can't totally do that using pure MATLAB code. On Windows, I tried different combinations, but the taskbar will still be on top (the one with the Start button):

%# 1)
sz = get(0, 'ScreenSize');
figure('Menubar','none', 'WindowStyle','modal', ...
    'Units','pixels', 'Position', [0 0 sz(3) sz(4)])

%# 2)
figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1])

%# 3)
hFig = figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1]);
set(hFig, 'Units','pixels')
p = get(hFig, 'Position');
set(hFig, 'Position', [1 31 p(3) p(4)-8]);

You would have to write a MEX function and call the the Win32 API directly. Fortunately, there should be existing submissions on FEX implementing such functionality.


Here is an example of creating a full screen figure, and drawing points with the mouse. I am using the WindowAPI solution by Jan Simon

%# open fullscreen figure
hFig = figure('Menubar','none');
WindowAPI(hFig, 'Position','full');

%# setup axis
axes('Color','k', 'XLim',[0 1], 'YLim',[0 1], ...
    'Units','normalized', 'Position',[0 0 1 1], ...
    'ButtonDownFcn',@onClick)

The callback function:

function onClick(hObj,ev)
    %# draw point
    p  = get(hObj,'CurrentPoint');
    line(p(1,1), p(1,2), 'Color','r', 'LineStyle','none', ...
        'Marker','.', 'MarkerSize',40, 'Parent',hObj)
end



回答2:


Check out psychophysics toolbox. It does exactly what you are looking for and more.




回答3:


Try this:

screen_size = get(0, 'ScreenSize');

buff=zeros(screen_size(3),screen_size(4));

for i=1:50
    buff(screen_size(3)/2-i,screen_size(4)/2+i)=100;

end
f1 = image(buff)
colormap(gray)

set(gcf,'windowstyle','modal');
set(gcf,'OuterPosition', screen_size); 
set(gcf,'position',screen_size); 
set(gcf,'Units','normal', 'outerposition',[0 0 1 1])
set(gca,'Visible', 'Off', 'Position',[0 0 1 1]) 

Use Alt+F4 (or equivalent) to kill the window. I don't fully understand why you have to do it this way, but it is the only way I've ever found to remove the window frame and make the plot extend full screen.



来源:https://stackoverflow.com/questions/7473686/matlab-how-to-draw-pixels-on-a-black-full-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!