What might be nice whichever option is selected, is to force it to keep the same aspect ratio when a window is stretched. I might be able to implement this.
This is essentially what I have implemented.
- Edit: Actually, perhaps you meant to keep the window size in the same aspect ratio when resized. I'm not doing that yet, but I can see how that would avoid the need for the letterbox/pillarbox affect.Since my last post, I've come up with a hybrid between your code and the "keep same aspect ratio when the window is stretched", in relation to the PictureBox. So what I've got it doing at the moment is that when the aspect ratio correction is turned on, it adjusts the GameScreen PictureBox size to the correct aspect ratio to fit in the current window size (depending on the current window dimensions, this might mean that it matches either the width or the height, whichever is appropriate for the current dimensions) and then it crops the window size to exactly fit that adjusted GameScreen size, which is using your code. Then if the user happens to adjust the window size, which I do a lot actually, then they will get the letterbox/pillarbox effect (
Edit: Although, as mentioned above, I guess we could dynamically adjust the window size to keep it cropped to the PictureBox when not in fullscreen mode). I don't think it makes sense to adjust the window size when exiting out of aspect correction mode though, in fact I think that is what caused the issue Charles reported. So I've removed the ClientSize adjustment that was happening when turning off aspect correction and instead the image just fills up, i.e. stretches to fill, whatever size the window is currently in (i.e. when aspect correction mode is off).
I'll create a branch on my repo, and a PR associated with it, so that you can see the changes I've made. I think it works quite well. I'll leave it unmerged and just as example code for now, until we agree how the whole thing should work.
I guess whichever way we go, the new code I've written works well for full screen, so is good for that scenario.