MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / clone

Method clone

src/rows.rs:48–74  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

46
47impl Clone for DynamicRows<'_, '_> {
48 fn clone(&self) -> Self {
49 Self {
50 width: self.width,
51 height: self.height,
52 f_pixels: self.f_pixels.clone(),
53 pixels: match &self.pixels {
54 PixelsSource::Pixels { rows, pixels } => PixelsSource::Pixels {
55 rows: rows.clone(),
56 pixels: pixels.clone(),
57 },
58 PixelsSource::Callback(_) => {
59 let area = self.width as usize * self.height as usize;
60 let mut out = Vec::with_capacity(area);
61 let out_rows = out.spare_capacity_mut()[..area].chunks_exact_mut(self.width as usize);
62 for (i, row) in out_rows.enumerate() {
63 self.row_rgba(row, i);
64 }
65 unsafe {
66 out.set_len(area);
67 }
68 let pixels = SeaCow::boxed(out.into_boxed_slice());
69 PixelsSource::for_pixels(pixels, self.width, self.height, self.width).unwrap()
70 },
71 },
72 gamma: self.gamma,
73 }
74 }
75}
76
77pub(crate) struct DynamicRowsIter<'parent, 'pixels, 'rows> {

Callers 3

liq_attr_copyFunction · 0.45
poke_itFunction · 0.45
r_callback_testFunction · 0.45

Calls 1

row_rgbaMethod · 0.80

Tested by 2

poke_itFunction · 0.36
r_callback_testFunction · 0.36