Skip to content

swf: Don't ignore Bitmap smoothing flags in SWF <8#10103

Draft
torokati44 wants to merge 1 commit intoruffle-rs:masterfrom
torokati44:bitmap-smoothing-flags
Draft

swf: Don't ignore Bitmap smoothing flags in SWF <8#10103
torokati44 wants to merge 1 commit intoruffle-rs:masterfrom
torokati44:bitmap-smoothing-flags

Conversation

@torokati44
Copy link
Copy Markdown
Member

@torokati44 torokati44 commented Mar 15, 2023

I think this comment: Bitmap smoothing only occurs in SWF version 8+.
Refers to this section in the AS reference:

However, the SWF spec does not mention the version-gate for this flag:

As for Lower versions use 0x40 and 0x41 type even when unsmoothed. it would be great if someone could come up with a real-world example of this.
I already have a counter-example: https://z0r.de/L/z0r-de_56.swf
This is a V6 SWF, and the bitmaps should appear smoothed.

And at any rate, handling this at the SWF read/write level might not be the best idea - I think it would be in a better place near rendering.

@Herschel
Copy link
Copy Markdown
Member

There is some complex behavior here to be careful of -- IIRC it has to do with a bitmap being in motion or not. In lower SWF version a one-frame movie would result in the smoothing behavior, while a multiple frame movie would be unsmoothed unless quality would be set to BEST.

I'll try to remember the exact behavior and get back to you!

@torokati44
Copy link
Copy Markdown
Member Author

Oh, this sounds similar to #5340!

@Herschel
Copy link
Copy Markdown
Member

I see this PR is only changing swf, and indeed those comments are incorrect! So this is good to add. We do need to make sure we emulate the above behavior at some point, though.

@Herschel
Copy link
Copy Markdown
Member

Herschel commented Mar 15, 2023

Actually thinking that this might be a little dangerous to merge as-is as this will incorrectly cause a lot of classic SWFs to be smoothed. We should either properly implement the _quality logic, or at least force-disable smoothing on the core side for SWF<v8 for now.

@torokati44
Copy link
Copy Markdown
Member Author

torokati44 commented Mar 15, 2023

Okay, I wasn't sure of it either, without any corresponding changes in the renderer - hence my wish for relevant real-world content.
I meant this mostly to gather our collective thoughts about how to handle this.

@torokati44 torokati44 marked this pull request as draft March 15, 2023 23:16
@Herschel
Copy link
Copy Markdown
Member

No worries, I'll try to post some minimal example SWFs.

@Herschel
Copy link
Copy Markdown
Member

Herschel commented Mar 15, 2023

You can try Wasted Sky from the demo page -- renders as unsmoothed in FP but smoothed with this PR.

Here's some minimal examples:
bitmap-smooth-swf7.zip
The singleframe SWF renders smoothed with default _quality = "HIGH";, but the multiframe one doesn't. I think the criteria may be as simple as checking swf.num_frames > 1.

To implement, perhaps we add a RenderBackend::set_allow_bitmap_smoothing accessor that will be set appropriately by core::display_object::Stage, or add a smoothing parameter to RenderBackend::set_quality.

@Herschel
Copy link
Copy Markdown
Member

Herschel commented Mar 16, 2023

Some more examples:
bitmap-smooth-flag.zip

2 frame SWF with 2 bitmaps, one flagged smooth and one unsmoothed,

  • bitmap-smooth-swf7-flag.swf: SWFv7, "HIGH" quality. Neither bitmap smoothed.
  • bitmap-smooth-swf7-flag-best.swf: SWFv7, "BEST" quality. One bitmap smoothed.
  • bitmap-smooth-swf8-flag.swf: SWFv8, "HIGH" quality. One bitmap smoothed.

The linked z0r SWF is 1 frame, so it honors the smoothing setting. The docs above indicate that the smoothing should take place "if the movie clip is static", which sounds like it should smooth if the timeline is stopped or something -- but so far my tests only shows it being affected by the # of frames on the timeline, regardless if it is stopped or not.

Another point of confusion is the Flash IDE will always export the bitmap smoothing flag when SWF version is set to 7 and below, regardless of what is set in the UI, so I had to manually edit these SWFs.

@danielhjacobs danielhjacobs added swf Related to the SWF format A-other Area: Not covered by other area labels T-fix Type: Bug fix (in something that's supposed to work already) labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-other Area: Not covered by other area labels swf Related to the SWF format T-fix Type: Bug fix (in something that's supposed to work already)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants