Skip to content

Change Frame from RgbaImage to DynamicImage#3020

Open
RunDevelopment wants to merge 1 commit into
image-rs:mainfrom
RunDevelopment:frame-dyn-image
Open

Change Frame from RgbaImage to DynamicImage#3020
RunDevelopment wants to merge 1 commit into
image-rs:mainfrom
RunDevelopment:frame-dyn-image

Conversation

@RunDevelopment

Copy link
Copy Markdown
Member

Fixes #2996.
Might also fix (idk) #2398.

This PR changes Frame to use an DynamicImage internally. This allows Frames and co. to represent animations that aren't RGBA8. As a side effect, this removes a forced DynImg -> Rgba8 conversion in ImageReader::into_frames, but also adds one in GifEncoder.

Not sure if we super duper want/need this.

Also, we may want to rename Frame::buffer to Frame::image (same for related methods), but I'm not sure if it's worth it.

@197g 197g left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably? I can't tell if I'm missing something here but then again it is rather conceptually simple.

Comment thread src/codecs/gif.rs
let frame_delay = img_frame.delay().into_ratio().to_integer();
// convert img_frame into RgbaImage
let mut rbga_frame = img_frame.into_buffer();
let mut rbga_frame = img_frame.into_buffer().to_rgba8();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd. While consistent with automatically converting for other encoding of DynamicImage, this can only happen here since it is DynamicImage and can not be another input that we'd reject automatically converting.

This feels like a right change but I do find it remarkable regardless.

@RunDevelopment

Copy link
Copy Markdown
Member Author

The change is rather simple, plus we're not really using the Frame API anywhere. Animations aren't that well tested, and GIF is the only animation encoder we have. Or put another way, almost everything that uses Frame did change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for different image types for into_frames

2 participants