1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Add texture filters to changelogs and improve docs

This commit is contained in:
Emil Ernerfeldt
2022-05-22 17:32:38 +02:00
parent 1a9a0d7ec8
commit cc148ca895
4 changed files with 41 additions and 30 deletions

View File

@@ -26,35 +26,6 @@ impl RetainedImage {
}
}
/// Set the texture filter to use for the image.
///
/// **Note:** If the texture has already been uploaded to the GPU, this will require
/// re-uploading the texture with the updated filter.
///
/// # Example
/// ```rust
/// # use egui_extras::RetainedImage;
/// # use egui::{Color32, epaint::{ColorImage, textures::TextureFilter}};
/// # let pixels = vec![Color32::BLACK];
/// # let color_image = ColorImage {
/// # size: [1, 1],
/// # pixels,
/// # };
/// #
/// // Upload a pixel art image without it getting blurry when resized
/// let image = RetainedImage::from_color_image("my_image", color_image)
/// .with_texture_filter(TextureFilter::Nearest);
/// ```
pub fn with_texture_filter(mut self, filter: TextureFilter) -> Self {
self.filter = filter;
// If the texture has already been uploaded, this will force it to be re-uploaded with the
// updated filter.
*self.texture.lock() = None;
self
}
/// Load a (non-svg) image.
///
/// Requires the "image" feature. You must also opt-in to the image formats you need
@@ -94,6 +65,35 @@ impl RetainedImage {
Self::from_svg_bytes(debug_name, svg_str.as_bytes())
}
/// Set the texture filter to use for the image.
///
/// **Note:** If the texture has already been uploaded to the GPU, this will require
/// re-uploading the texture with the updated filter.
///
/// # Example
/// ```rust
/// # use egui_extras::RetainedImage;
/// # use egui::{Color32, epaint::{ColorImage, textures::TextureFilter}};
/// # let pixels = vec![Color32::BLACK];
/// # let color_image = ColorImage {
/// # size: [1, 1],
/// # pixels,
/// # };
/// #
/// // Upload a pixel art image without it getting blurry when resized
/// let image = RetainedImage::from_color_image("my_image", color_image)
/// .with_texture_filter(TextureFilter::Nearest);
/// ```
pub fn with_texture_filter(mut self, filter: TextureFilter) -> Self {
self.filter = filter;
// If the texture has already been uploaded, this will force it to be re-uploaded with the
// updated filter.
*self.texture.lock() = None;
self
}
/// The size of the image data (number of pixels wide/high).
pub fn size(&self) -> [usize; 2] {
self.size