getframe pixel dimensions do not match figure position

5 次查看(过去 30 天)
When I use getframe.m, I expect it to produce an image that exactly matches what I see on screen. But getframe produces an image whose pixel dimensions do not match the size of the figure -- if the figure is on the built-in display of my laptop. If I move the figure to the external display (connected to my laptop), getframe produces an imge whose pixel dimensions do match the size of the figure. I'm running Matlab R2020b on MacOS 11.6.
How can I make getframe work as expected on my built-in display?
Example code:
>> figure; image
>> get(gcf,'position') % on built-in display
ans =
677 160 560 420
>> snap = getframe(gcf); size(snap.cdata) % does not match!
ans =
840 1120 3
>> get(gcf,'position') % on external display
ans =
789 1074 560 420
>> snap = getframe(gcf); size(snap.cdata) % does match
ans =
420 560 3

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by