mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
epaint: Added ColorImage::from_rgba_vec constructor
This is typically used when there's an existing image buffer and memory copying is to be avoided.
This commit is contained in:
@@ -123,6 +123,16 @@ impl ColorImage {
|
|||||||
Self { size, pixels }
|
Self { size, pixels }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a [`ColorImage`] with an existing image buffer.
|
||||||
|
///
|
||||||
|
/// This is typically used when you want to avoid unnecessary memory copying by reusing an existing image buffer.
|
||||||
|
///
|
||||||
|
/// Panics if `size[0] * size[1] != pixels.len()`.
|
||||||
|
pub fn from_rgba_vec(size: [usize; 2], pixels: Vec<Color32>) -> Self {
|
||||||
|
assert_eq!(size[0] * size[1], pixels.len());
|
||||||
|
Self { size, pixels }
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a [`ColorImage`] from flat opaque gray data.
|
/// Create a [`ColorImage`] from flat opaque gray data.
|
||||||
///
|
///
|
||||||
/// Panics if `size[0] * size[1] != gray.len()`.
|
/// Panics if `size[0] * size[1] != gray.len()`.
|
||||||
|
|||||||
Reference in New Issue
Block a user