Add basic ico support (#40822)
Closes https://github.com/zed-industries/zed/discussions/40763 <img width="867" height="1088" alt="Screenshot 2025-10-21 at 23 14 47" src="https://github.com/user-attachments/assets/d691fb2a-afc6-4445-a335-054ef164e0d3" /> Also improves error handling on image open failure: <img width="864" height="1083" alt="Screenshot 2025-10-21 at 23 14 30" src="https://github.com/user-attachments/assets/d5388b61-995f-441b-b375-ad5136d1533b" /> Release Notes: - Added basic ico support, improved unsupported image handling
This commit is contained in:
@@ -1644,6 +1644,8 @@ pub enum ImageFormat {
|
||||
Bmp,
|
||||
/// .tif or .tiff
|
||||
Tiff,
|
||||
/// .ico
|
||||
Ico,
|
||||
}
|
||||
|
||||
impl ImageFormat {
|
||||
@@ -1657,6 +1659,7 @@ impl ImageFormat {
|
||||
ImageFormat::Svg => "image/svg+xml",
|
||||
ImageFormat::Bmp => "image/bmp",
|
||||
ImageFormat::Tiff => "image/tiff",
|
||||
ImageFormat::Ico => "image/ico",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1670,6 +1673,7 @@ impl ImageFormat {
|
||||
"image/svg+xml" => Some(Self::Svg),
|
||||
"image/bmp" => Some(Self::Bmp),
|
||||
"image/tiff" | "image/tif" => Some(Self::Tiff),
|
||||
"image/ico" => Some(Self::Ico),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -1776,6 +1780,7 @@ impl Image {
|
||||
ImageFormat::Webp => frames_for_image(&self.bytes, image::ImageFormat::WebP)?,
|
||||
ImageFormat::Bmp => frames_for_image(&self.bytes, image::ImageFormat::Bmp)?,
|
||||
ImageFormat::Tiff => frames_for_image(&self.bytes, image::ImageFormat::Tiff)?,
|
||||
ImageFormat::Ico => frames_for_image(&self.bytes, image::ImageFormat::Ico)?,
|
||||
ImageFormat::Svg => {
|
||||
let pixmap = svg_renderer.render_pixmap(&self.bytes, SvgSize::ScaleFactor(1.0))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user