bugGNU Octave - Bugs: bug #65540, getframe use wrong rect to pixel...


bug #65540: getframe use wrong rect to pixel transformation at Retina display

Submitter:  Alexander <aknew>
Submitted:  Sat 30 Mar 2024 03:59:34 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 8.4.0 Operating System:  * Any
Fixed Release:  None Planned Release:  9.2.0 (current stable)
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Tue 09 Apr 2024 06:52:09 AM UTC, comment #8: 

Thank you for testing.

Closing as fixed.

@aknew: Could you please also check if the patch for cross-platform High-DPI support doesn't break on macOS?

Markus Mützel <mmuetzel>
Group administrator
Mon 08 Apr 2024 07:59:33 PM UTC, comment #7: 

I've also checked this patch on macOS and it works too. Thank you!

Alexander <aknew>
Fri 05 Apr 2024 05:58:59 PM UTC, comment #6: 

The patch missed some parts.
I hope it is more complete now with these changes:

Markus Mützel <mmuetzel>
Group administrator
Fri 05 Apr 2024 03:21:06 PM UTC, comment #5: 

Thank you for testing.

Assuming that this will also address the issue on macOS, I pushed the patch to the stable branch:

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Fri 05 Apr 2024 03:13:13 PM UTC, comment #4: 

Also works fine with qt5, though figures are smaller.


Dmitri A. Sergatskov <dasergatskov>
Fri 05 Apr 2024 03:08:42 PM UTC, comment #3: 

Yes. The patch fixed the problem on linux/Qt6 200% scaling.


Dmitri A. Sergatskov <dasergatskov>
Fri 05 Apr 2024 02:50:37 PM UTC, comment #2: 

I'm seeing the same behavior with high DPI on Windows using Qt6.

The attached patch fixes the issue for me. Does it also work on Linux or macOS?

(file #55923)

Markus Mützel <mmuetzel>
Group administrator
Sat 30 Mar 2024 05:32:26 PM UTC, comment #1: 

I can confirm it on linux (octave 9.1.1, Qt 6.6.2)
with display that uses 200% scaling.


Dmitri A. Sergatskov <dasergatskov>
Sat 30 Mar 2024 03:59:34 PM UTC, original submission:  

Sample code (No matter what or how you draw something, I caught this bug with surf):

t = linspace(0,2*pi,100)';
x = cos(t);
y = sin(t);
[img map] = rgb2ind(frame2im(getframe(gcf)));
imwrite(img, map, 'getframe_test.png', 'png', 'WriteMode', 'overwrite');

Expected result: saved file with whole figure
Actual result: saved file with only bottom left quarter of figure

I also tried using set(gcf, 'Position', rect); and called getframe with this rect (or part of it) and got the same result

I suppose that this behaviour based on Apple's high resolution feature (https://developer.apple.com/library/archive/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) when rect (0,0,10,10) have 20X20 pixels at Retina displays (like mine), but getframe thinks that rect units and pixels are the same thing and returns only 10X10 pixels. This assumption is confirmed by logging pos and size(cdata) near line 124 into getframe.m - pos (3,4) really like size cdata divided by 2 (Actually I just add *2 at lines 118 and 121, but it is ugly kludge which works only for my current script when I need whole figure)

Alexander <aknew>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by aknew (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-04-09 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2024-04-05 mmuetzel StatusPatch Submitted Ready For Test
    2024-04-05 mmuetzel Attached File- Added bug65540-getframe-highDPI.patch, #55923
        StatusNone Patch Submitted
        Operating SystemMac OS Any
        Planned ReleaseNone 9.2.0 (current stable)

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code