mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:42:27 +00:00
fix(metafile): preserve viewport scaling before inferred target
This commit is contained in:
1 parent
7585d2df79
commit
8644532ed7
2 files changed
+18
-1
No files matched your search
@@ -2744,3 +2744,17 @@ fn wmf_viewport_scaling_does_not_resize_the_player_frame() {
|
||||
assert_eq!(rect_extent(&p.items[0]), (0.0, 0.0, 100.0, 100.0));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wmf_viewport_scaling_before_first_window_is_retained() {
|
||||
let recs = [
|
||||
wrec(0x0103, &h16(8)),
|
||||
wrec(0x0412, &cat(vec![h16(1), h16(1), h16(2), h16(1)])),
|
||||
wrec(0x020C, &cat(vec![h16(100), h16(100)])),
|
||||
wrec(0x041B, &cat(vec![h16(100), h16(100), h16(0), h16(0)])),
|
||||
];
|
||||
let p = parse(&wmf(&recs, None)).unwrap();
|
||||
assert_eq!((p.width, p.height), (100.0, 100.0));
|
||||
assert_eq!(p.skipped_records, 0);
|
||||
assert_eq!(rect_extent(&p.items[0]), (0.0, 0.0, 50.0, 100.0));
|
||||
}
|
||||
@@ -64,7 +64,10 @@ pub(crate) fn parse(input: Bytes) -> Result<(Canvas, Option<Frame>), Error> {
|
||||
if func == 0x020C && cv.window_set && player_target.is_none() && !cv.viewport_set {
|
||||
let we = cv.map.window_ext();
|
||||
let target = (we.0.abs(), we.1.abs());
|
||||
cv.play_into(None, target);
|
||||
// Before an explicit viewport, its default (1, 1) retains any
|
||||
// SCALEVIEWPORTEXT factors already applied by the file.
|
||||
let scale = cv.map.viewport_ext();
|
||||
cv.play_into(None, (target.0 * scale.0, target.1 * scale.1));
|
||||
player_target = Some(target);
|
||||
}
|
||||
parsed += 1;
|
||||
|
||||
Reference in new issue
Block a user