Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/common/src/tag_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ impl SwfMovie {
}

/// Construct a movie based on a loaded image (JPEG, GIF or PNG).
pub fn from_loaded_image(url: String, length: usize) -> Self {
let header = HeaderExt::default_with_uncompressed_len(length as i32);
pub fn from_loaded_image(url: String, length: usize, width: u32, height: u32) -> Self {
let stage_size = Rectangle::ZERO
.with_width(Twips::from_pixels_i32(width as i32))
.with_height(Twips::from_pixels_i32(height as i32));
let header = HeaderExt::default_with_uncompressed_len(length as i32, stage_size);
let sandbox_type = SandboxType::infer(url.as_str(), &header);
let mut movie = Self {
header,
Expand Down
10 changes: 9 additions & 1 deletion core/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,15 @@ impl<'gc> MovieLoader<'gc> {
Arc::new(movie)
}
ContentType::Gif | ContentType::Jpeg | ContentType::Png => {
Arc::new(SwfMovie::from_loaded_image(url.clone(), length))
let (width, height) =
ruffle_render::utils::decode_define_bits_jpeg_dimensions(data)
.unwrap_or((0, 0));
Arc::new(SwfMovie::from_loaded_image(
url.clone(),
length,
width,
height,
))
}
ContentType::Unknown => Arc::new(SwfMovie::error_movie(url.clone())),
};
Expand Down
4 changes: 2 additions & 2 deletions swf/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ impl HeaderExt {
}

/// Returns the header for a loaded image (JPEG, GIF or PNG).
pub fn default_with_uncompressed_len(length: i32) -> Self {
pub fn default_with_uncompressed_len(length: i32, stage_size: Rectangle<Twips>) -> Self {
let header = Header {
compression: Compression::None,
version: 0,
stage_size: Default::default(),
stage_size,
frame_rate: Fixed8::ONE,
num_frames: 1,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ childSandboxBridge: null
content: [object Bitmap]
contentType: image/jpeg
frameRate: 1
height: 0
height: 140
isURLInaccessible: false
loader: [object Loader]
loaderURL: alf.jpg
Expand All @@ -45,4 +45,4 @@ sharedEvents: [object EventDispatcher]
swfVersion: 0
uncaughtErrorEvents: [object UncaughtErrorEvents]
url: alf.jpg
width: 0
width: 140
Loading