Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Core: Fixes To Display Capture/Save Resolution #527

Merged
merged 4 commits into from
Apr 26, 2023

Conversation

scottrules44
Copy link
Contributor

@scottrules44 scottrules44 commented Mar 1, 2023

This is aimed to fix #515 (and probably a few more)
I tested this on my iPhone 14 Pro and iPad Air(which was originally wrong), and this gave me the correct image output resolution :) . Will try to test on more devices I have access to (including Android), but having trouble running iPhone "template" project on iOS simulators(get a bunch of undefined symbols).

@scottrules44 scottrules44 requested a review from Shchvova as a code owner March 1, 2023 04:14
@ggcrunchy
Copy link
Contributor

@scottrules44 Sent you a DM in Discord about this.

@scottrules44
Copy link
Contributor Author

Just tried on a iPad Pro 10.5 and iPad 6th gen and both return correct screen resolutions

@scottrules44
Copy link
Contributor Author

scottrules44 commented Mar 2, 2023

^ I noticed when I switch to Android my Pixel 6a was off a bit, so I started over from scratch and based off @ggcrunchy comments(ty btw) I used more precise method for getting the width and height by passing Real/float values into "ContentToScreen".
This work across every device mentioned perviously and my iPhone SE, Pixel 2XL, Pixel 6a, Kindle Fire, and Samsung a025AZ. Very confident in this version

@Shchvova It should be noted this won't breaking anything because I basically created a variant of ContentToScreen, one that take in reals/floats and one that takes ints. :)

@scottrules44
Copy link
Contributor Author

scottrules44 commented Mar 2, 2023

This is the test project I used btw
assets2.zip

@Shchvova Shchvova merged commit 2ef4961 into coronalabs:master Apr 26, 2023
@scottrules44 scottrules44 deleted the DisplayCaptureSaveFix branch April 30, 2023 18:15
@zero-meta
Copy link
Contributor

zero-meta commented May 10, 2023

@scottrules44 After this pull request, display.colorSample doesn't work as expected.
I use MacOS simulator 3690. Here is my test example:
testColorSample.zip

local bkg = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight )
bkg:setFillColor(1, 0, 0, 1)

local function onColorSample( event )
    print( "Sampling pixel at position (" .. event.x .. "," .. event.y .. ")" )
    print( "R = " .. event.r )
    print( "G = " .. event.g )
    print( "B = " .. event.b )
    print( "A = " .. event.a )
end
 
timer.performWithDelay(100, function()
    display.colorSample( display.contentCenterX, display.contentCenterY, onColorSample )
end)

Now it always print R = 0, G = 0, B = 0, A = 0.
And I found the output depends on what width, height value set in config.lua.
If I set width = 320, height = 480, it will get correct color.

application =
{
    content = 
    { 
        fps = 60,
        width = 1536,
        height = 2048,
        scale = "letterbox",
        xAlign = "center",
        yAlign = "center",
    }
}

@scottrules44
Copy link
Contributor Author

@scottrules44 After this pull request, display.colorSample doesn't work as expected. I use MacOS simulator 3690. Here is my test example: testColorSample.zip

local bkg = display.newRect(display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight )
bkg:setFillColor(1, 0, 0, 1)

local function onColorSample( event )
    print( "Sampling pixel at position (" .. event.x .. "," .. event.y .. ")" )
    print( "R = " .. event.r )
    print( "G = " .. event.g )
    print( "B = " .. event.b )
    print( "A = " .. event.a )
end
 
timer.performWithDelay(100, function()
    display.colorSample( display.contentCenterX, display.contentCenterY, onColorSample )
end)

Now it always print R = 0, G = 0, B = 0, A = 0. And I found the output depends on what width, height value set in config.lua. If I set width = 320, height = 480, it will get correct color.

application =
{
    content = 
    { 
        fps = 60,
        width = 1536,
        height = 2048,
        scale = "letterbox",
        xAlign = "center",
        yAlign = "center",
    }
}

Fixed with #575
I get
R = 1
G = 0
B = 0
A = 1

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Simulator]: Screenshots for some resolutions don't have exact size of the simulator resolution
4 participants