Skip to content

Add ICO BMP encoder#3044

Open
RunDevelopment wants to merge 6 commits into
image-rs:mainfrom
RunDevelopment:ico-bmp-encoder
Open

Add ICO BMP encoder#3044
RunDevelopment wants to merge 6 commits into
image-rs:mainfrom
RunDevelopment:ico-bmp-encoder

Conversation

@RunDevelopment

Copy link
Copy Markdown
Member

Resolves #2192

This PR adds an ICO BMP encoder. It supports Rgba8 and Rgb8 image data. Rgb8 is encoded as 32-bit 0RGB as 24-bit 24-bit is not allowed.

The test currently fails because the decoder doesn't support 0RGB yet (#3012).


Since @197g reviewed most of this PR in an accidental commit in #3042, I'll recreate her comments here. I won't recreate comments I already resolved.

Comment thread src/codecs/ico/encoder.rs
Comment on lines +91 to +96
pub fn as_bmp(
buf: &[u8],
width: u32,
height: u32,
color_type: ExtendedColorType,
) -> ImageResult<Self> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can this be non-pub? I'm thinking we should be trying to reduce interfaces that take width, height, color, buf as separate parameters.

I mirrored as_png. I'm not against a nicer API, but I think it should be consistent for both.

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'll note it down for the review list of v1.0, it's not an absolute stopper for doing that as it's easily compatible (just a little legacy code to carry around).

Comment thread src/codecs/ico/encoder.rs
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.

An invalid ICO image is generated when it includes multiple BMP images

2 participants