Story Viewer: fix situational incorrect scaling of background images

This commit is contained in:
Charles Dang 2017-04-15 23:36:16 +11:00
parent 63403c90a5
commit e150c7c070

View file

@ -152,24 +152,16 @@ void story_viewer::display_part(window& window)
std::string width_formula = "(image_original_width)"; std::string width_formula = "(image_original_width)";
std::string height_formula = "(image_original_height)"; std::string height_formula = "(image_original_height)";
// If scale width is true, the image will be stretched to screen width. if(layer.scale_horizontally() && preserve_ratio) {
if(layer.scale_horizontally()) { height_formula = "(min((image_original_height * screen_width / image_original_width), height))";
width_formula = "(width)"; } else {
// Override height formula to preserve ratio, if applicable.
if(preserve_ratio) {
height_formula = "(image_original_height * width / image_original_width)";
}
}
// If scale height is true, the image will be stretched to screen height.
if(layer.scale_vertically()) {
height_formula = "(height)"; height_formula = "(height)";
// Override width formula to preserve ratio, if applicable.
if(preserve_ratio) {
width_formula = "(image_original_width * height / image_original_height)";
} }
if(layer.scale_vertically() && preserve_ratio) {
width_formula = "(min((image_original_width * screen_height / image_original_height), width))";
} else {
width_formula = "(width)";
} }
// Background layers are always centered. // Background layers are always centered.