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.
@ -314,8 +306,8 @@ void story_viewer::draw_floating_image(window& window, floating_image_list::cons
y_ss << "(trunc(fi_ref_y * base_scale_y) + base_origin.y"; y_ss << "(trunc(fi_ref_y * base_scale_y) + base_origin.y";
if(floating_image.centered()) { if(floating_image.centered()) {
x_ss << "- (image_original_width / 2)"; x_ss << " - (image_original_width / 2)";
y_ss << "- (image_original_height / 2)"; y_ss << " - (image_original_height / 2)";
} }
x_ss << " where fi_ref_x = " << floating_image.ref_x() << ")"; x_ss << " where fi_ref_x = " << floating_image.ref_x() << ")";