Skip to content

gpui: Fix BGRA conversion for SVG rendering#52641

Merged
MrSubidubi merged 2 commits intozed-industries:mainfrom
nakashima-hikaru:fix/gpui-svg-color-rendering
Mar 29, 2026
Merged

gpui: Fix BGRA conversion for SVG rendering#52641
MrSubidubi merged 2 commits intozed-industries:mainfrom
nakashima-hikaru:fix/gpui-svg-color-rendering

Conversation

@nakashima-hikaru
Copy link
Copy Markdown
Contributor

@nakashima-hikaru nakashima-hikaru commented Mar 28, 2026

Description

Fixes swapped red/blue channels when rendering SVG images.

Describe the bug

When rendering a full-color SVG into an Image object using Image::from_bytes(ImageFormat::Svg, ...) on macOS, the resulting bitmap has its Red and Blue channels swapped. For example, a color specified as #38BDF8 (Light Blue) in the SVG source appears as yellowish in the rendered GPUI view.

Steps to reproduce

  1. Create a GPUI application.
  2. Generate or load an SVG string containing a specific color, for example:
   <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
     <rect width="100" height="100" fill="#38BDF8"/>
   </svg>
  1. Load this SVG into an Image object:
   let image = Arc::new(Image::from_bytes(
       ImageFormat::Svg,
       svg_string.into_bytes(),
   ));
  1. Display this image in a view using an img() element.

Expected behavior

The rectangle should be rendered in Light Blue (#38BDF8).

Actual behavior

The rectangle is rendered in Yellowish Color (#F8BD38).

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

  • Fixed swapped color channels when pasting SVG images from the clipboard.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 28, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @nakashima-hikaru on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 28, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, maxbrunsfeld and nathansobo and removed request for a team March 28, 2026 23:08
@nakashima-hikaru
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 28, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @nakashima-hikaru on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 28, 2026

The cla-bot has been summoned, and re-checked this pull request!

@nakashima-hikaru
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 28, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Mar 28, 2026

The cla-bot has been summoned, and re-checked this pull request!

@nakashima-hikaru nakashima-hikaru changed the title gpui: Enable BGRA conversion for SVG rendering gpui: Fix BGRA conversion for SVG rendering Mar 28, 2026
@MrSubidubi MrSubidubi self-assigned this Mar 29, 2026
Copy link
Copy Markdown
Member

@MrSubidubi MrSubidubi left a comment

Choose a reason for hiding this comment

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

Nice find and very much appreciate the test you added for this!

I went ahead and removed the parameter altogether, given that it is now true throughout the codebase and I think that other consumers would probably expect the image to always be in the proper color space.

In any case, thank you for this and congratulations to your first contribution! 🎉

@MrSubidubi MrSubidubi enabled auto-merge (squash) March 29, 2026 14:37
@MrSubidubi MrSubidubi merged commit dbb8afe into zed-industries:main Mar 29, 2026
30 checks passed
@nakashima-hikaru nakashima-hikaru deleted the fix/gpui-svg-color-rendering branch March 29, 2026 14:49
@nakashima-hikaru
Copy link
Copy Markdown
Contributor Author

Thanks a lot for the review and for cleaning that up.
As a fan of Zed, I’ll be cheering the project on.

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

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants