I'm very surprised there is no commentary here. It seems either people don't allow their users to adjust zoom levels on the fly, or they directly manage the magnification on their own without the use of SetViewZoom().
I'm positive my code is mathematically sound, but it doesn't produce the expected results. So, I go back and question my first principles. I removed the restrictions on how much I could scroll the viewport so that I could manually move it around and see what values it should have had in order to correctly stop at the edges of the expanded image. Here's a summary of some of the data:
Screen is 1024 x 768, giving aspect ratio of 1.33
actual world height: 1568
Zoom level: 1.0
min/max screen offset: 0 / 800
theoretical world size/actual world size: 1568 / 1568
Zoom level: 1.5
min/max screen offset: -128 / 928
theoretical world size/actual world size: 2352 / 1824
Zoom level: 2.0
min/max screen offset: -192 / 992
theoretical world size/actual world size: 3136 / 1952
**~**
actual world height: 1760
Zoom level: 1.0
min/max screen offset: 0 / 992
theoretical world size/actual world size: 1760 / 1760
Zoom level: 1.5
min/max screen offset: -128 / 1120
theoretical world size/actual world size: 2640 / 2016
Zoom level: 2.0
min/max screen offset: -192 / 1184
theoretical world size/actual world size: 3520 / 2144
**~**
actual world height: 1952
Zoom level: 1.0
min/max screen offset: 0 / 1184
theoretical world size/actual world size: 1952 / 1952
Zoom level: 1.5
min/max screen offset: -128 / 1312
theoretical world size/actual world size: 2928 / 2208
Zoom level: 2.0
min/max screen offset: -192 / 1376
theoretical world size/actual world size: 3904 / 2336
**~**
actual world height: 2144
Zoom level: 1.0
min/max screen offset: 0 / 1376
theoretical world size/actual world size: 2144 / 2144
Zoom level: 1.5
min/max screen offset: -128 / 1504
theoretical world size/actual world size: 3216 / 2400
Zoom level: 2.0
min/max screen offset: -192 / 1568
theoretical world size/actual world size: 4288 / 2528
I had assumed that an expanded world would move out in all directions, moving the top left corner from (0, 0) to some (-x, -y) location. It does, but the amount of expansion is not as simple as taking your original world size and multiplying it by the zoom factor. The magnification is limited by a factor more complicated than basic scale you pass along. For example, it turns out that with my 1024 x 768 screen, magnification by 1.5 stretches the world out by exactly 256 pixels, no matter the original size of the world. If I go from 1.5 to 2.0, then the world stretches by another 128 pixels. I haven't been able to figure out yet where these values are coming from. The implication would also be that going from 1.0 down to 0.5 zoom would contract the world by 512 pixels, but this doesn't seem to be the case. I'll have to collect more data on that.
Goo Goo G'Joob!