Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/agent_ui/src/conversation_view/thread_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7707,6 +7707,7 @@ impl ThreadView {
gpui::ImageFormat::Bmp => "BMP",
gpui::ImageFormat::Tiff => "TIFF",
gpui::ImageFormat::Ico => "ICO",
gpui::ImageFormat::Pnm => "PNM",
};
let dimensions = image::ImageReader::new(std::io::Cursor::new(image.bytes()))
.with_guessed_format()
Expand Down
4 changes: 4 additions & 0 deletions crates/gpui/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,8 @@ pub enum ImageFormat {
Tiff,
/// .ico
Ico,
/// Netpbm image formats (.pbm, .ppm, .pgm).
Pnm,
}

impl ImageFormat {
Expand All @@ -1995,6 +1997,7 @@ impl ImageFormat {
ImageFormat::Bmp => "image/bmp",
ImageFormat::Tiff => "image/tiff",
ImageFormat::Ico => "image/ico",
ImageFormat::Pnm => "image/x-portable-anymap",
}
}

Expand Down Expand Up @@ -2131,6 +2134,7 @@ impl Image {
.render_single_frame(&self.bytes, 1.0)
.map_err(Into::into);
}
ImageFormat::Pnm => frames_for_image(&self.bytes, image::ImageFormat::Pnm)?,
};

Ok(Arc::new(RenderImage::new(frames)))
Expand Down
3 changes: 2 additions & 1 deletion crates/gpui_linux/src/linux/x11/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ x11rb::atom_manager! {
BMP__MIME: ImageFormat::mime_type(ImageFormat::Bmp ).as_bytes(),
TIFF_MIME: ImageFormat::mime_type(ImageFormat::Tiff).as_bytes(),
ICO__MIME: ImageFormat::mime_type(ImageFormat::Ico ).as_bytes(),

PNM__MIME: ImageFormat::mime_type(ImageFormat::Pnm ).as_bytes(),
// This is just some random name for the property on our window, into which
// the clipboard owner writes the data we requested.
ARBOARD_CLIPBOARD,
Expand Down Expand Up @@ -1005,6 +1005,7 @@ impl Clipboard {
ImageFormat::Bmp => self.inner.atoms.BMP__MIME,
ImageFormat::Tiff => self.inner.atoms.TIFF_MIME,
ImageFormat::Ico => self.inner.atoms.ICO__MIME,
ImageFormat::Pnm => self.inner.atoms.PNM__MIME,
};
let data = vec![ClipboardData {
bytes: image.bytes,
Expand Down
6 changes: 6 additions & 0 deletions crates/gpui_macos/src/pasteboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl From<ImageFormat> for UTType {
ImageFormat::Bmp => Self::bmp(),
ImageFormat::Svg => Self::svg(),
ImageFormat::Ico => Self::ico(),
ImageFormat::Pnm => Self::pnm(),
}
}
}
Expand Down Expand Up @@ -320,6 +321,11 @@ impl UTType {
Self(unsafe { NSPasteboardTypeTIFF }) // This is a rare case where there's a built-in NSPasteboardType
}

pub fn pnm() -> Self {
//https://en.wikipedia.org/w/index.php?title=Netpbm&oldid=1336679433 under Uniform Type Identifier
Self(unsafe { ns_string("public.pbm") })
}

fn inner(&self) -> *const Object {
self.0
}
Expand Down
1 change: 1 addition & 0 deletions crates/project/src/image_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ fn create_gpui_image(content: Vec<u8>) -> anyhow::Result<Arc<gpui::Image>> {
image::ImageFormat::Bmp => gpui::ImageFormat::Bmp,
image::ImageFormat::Tiff => gpui::ImageFormat::Tiff,
image::ImageFormat::Ico => gpui::ImageFormat::Ico,
image::ImageFormat::Pnm => gpui::ImageFormat::Pnm,
format => anyhow::bail!("Image format {format:?} not supported"),
},
content,
Expand Down
Loading