gpui: Fix BGRA conversion for SVG rendering#52641
gpui: Fix BGRA conversion for SVG rendering#52641MrSubidubi merged 2 commits intozed-industries:mainfrom
Conversation
|
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 check |
|
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'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
MrSubidubi
left a comment
There was a problem hiding this comment.
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! 🎉
|
Thanks a lot for the review and for cleaning that up. |
### 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. 1. Generate or load an SVG string containing a specific color, for example: ```xml <svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"> <rect width="100" height="100" fill="#38BDF8"/> </svg> ``` 3. Load this SVG into an Image object: ```rust let image = Arc::new(Image::from_bytes( ImageFormat::Svg, svg_string.into_bytes(), )); ``` 4. 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: - [X] I've reviewed my own diff for quality, security, and reliability - [X] Unsafe blocks (if any) have justifying comments - [X] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [X] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable ### Closes #ISSUE ### Release Notes: - Fixed swapped color channels when pasting SVG images from the clipboard. --------- Co-authored-by: MrSubidubi <finn@zed.dev>
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
Expected behavior
The rectangle should be rendered in Light Blue (#38BDF8).
Actual behavior
The rectangle is rendered in Yellowish Color (#F8BD38).
Self-Review Checklist:
Closes #ISSUE
Release Notes: