zed/crates/svg_preview
hnakashima dbb8afe676
gpui: Fix BGRA conversion for SVG rendering (#52641)
### 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>
2026-03-29 14:43:05 +00:00
..
src gpui: Fix BGRA conversion for SVG rendering (#52641) 2026-03-29 14:43:05 +00:00
Cargo.toml Add item for opening Markdown/SVG files in preview tab in right-click menu (#47821) 2026-01-28 00:19:13 -03:00
LICENSE-GPL Add SVG preview (#32694) 2025-06-27 09:08:05 +00:00