long newHeight2 = 0;
long newWidth2 = 0;
if (ratio <= 1.0) { // portrait and square
if (width <= mHeight) {
newHeight2 = (long)((width / 2L) / ratio);
<BUG>newWidth2 = (long)(width / 2L);
} else { // switch landscape --> portrait</BUG>
float pixelDeg = (float)App.mainActivity.getMap().getHeight()/(float)width; // height was the old width
newWidth2 = (long)(App.mainActivity.getMap().getWidth() / pixelDeg)/2L;
newHeight2 = (long)(newWidth2 / ratio );

long newHeight2 = 0;
long newWidth2 = 0;
if (ratio <= 1.0) { // portrait and square
if (width <= mHeight) {
newHeight2 = (long)((width / 2L) / ratio);
newWidth2 = width / 2L;
} else { // switch landscape --> portrait
float pixelDeg = (float)App.mainActivity.getMap().getHeight()/(float)width; // height was the old width
newWidth2 = (long)(App.mainActivity.getMap().getWidth() / pixelDeg)/2L;
newHeight2 = (long)(newWidth2 / ratio );
