Files
phy/image/trait.GenericImageView.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

47 lines
21 KiB
HTML

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Trait to inspect an image."><title>GenericImageView in image - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="image" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../image/index.html">image</a><span class="version">0.25.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Generic<wbr>Image<wbr>View</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Pixel" title="Pixel">Pixel</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.dimensions" title="dimensions">dimensions</a></li><li><a href="#tymethod.get_pixel" title="get_pixel">get_pixel</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.height" title="height">height</a></li><li><a href="#method.in_bounds" title="in_bounds">in_bounds</a></li><li><a href="#method.pixels" title="pixels">pixels</a></li><li><a href="#method.unsafe_get_pixel" title="unsafe_get_pixel">unsafe_get_pixel</a></li><li><a href="#method.view" title="view">view</a></li><li><a href="#method.width" title="width">width</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate image</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">image</a></span><h1>Trait <span class="trait">GenericImageView</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/image/image.rs.html#827-900">Source</a> </span></div><pre class="rust item-decl"><code>pub trait GenericImageView {
type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a>: <a class="trait" href="trait.Pixel.html" title="trait image::Pixel">Pixel</a>;
// Required methods
fn <a href="#tymethod.dimensions" class="fn">dimensions</a>(&amp;self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>);
<span class="item-spacer"></span> fn <a href="#tymethod.get_pixel" class="fn">get_pixel</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; Self::<a class="associatedtype" href="trait.GenericImageView.html#associatedtype.Pixel" title="type image::GenericImageView::Pixel">Pixel</a>;
// Provided methods
fn <a href="#method.width" class="fn">width</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.height" class="fn">height</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.in_bounds" class="fn">in_bounds</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a> { ... }
<span class="item-spacer"></span> unsafe fn <a href="#method.unsafe_get_pixel" class="fn">unsafe_get_pixel</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; Self::<a class="associatedtype" href="trait.GenericImageView.html#associatedtype.Pixel" title="type image::GenericImageView::Pixel">Pixel</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.pixels" class="fn">pixels</a>(&amp;self) -&gt; <a class="struct" href="struct.Pixels.html" title="struct image::Pixels">Pixels</a>&lt;'_, Self&gt; <a href="#" class="tooltip" data-notable-ty="Pixels&lt;&#39;_, Self&gt;"></a>
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
<span class="item-spacer"></span> fn <a href="#method.view" class="fn">view</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, width: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, height: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="struct.SubImage.html" title="struct image::SubImage">SubImage</a>&lt;&amp;Self&gt;
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait to inspect an image.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>image::{GenericImageView, Rgb, RgbImage};
<span class="kw">let </span>buffer = RgbImage::new(<span class="number">10</span>, <span class="number">10</span>);
<span class="kw">let </span>image: <span class="kw-2">&amp;</span><span class="kw">dyn </span>GenericImageView&lt;Pixel=Rgb&lt;u8&gt;&gt; = <span class="kw-2">&amp;</span>buffer;</code></pre></div>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Pixel" class="method"><a class="src rightside" href="../src/image/image.rs.html#829">Source</a><h4 class="code-header">type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a>: <a class="trait" href="trait.Pixel.html" title="trait image::Pixel">Pixel</a></h4></section></summary><div class="docblock"><p>The type of pixel.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.dimensions" class="method"><a class="src rightside" href="../src/image/image.rs.html#832">Source</a><h4 class="code-header">fn <a href="#tymethod.dimensions" class="fn">dimensions</a>(&amp;self) -&gt; (<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>)</h4></section></summary><div class="docblock"><p>The width and height of this image.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_pixel" class="method"><a class="src rightside" href="../src/image/image.rs.html#857">Source</a><h4 class="code-header">fn <a href="#tymethod.get_pixel" class="fn">get_pixel</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; Self::<a class="associatedtype" href="trait.GenericImageView.html#associatedtype.Pixel" title="type image::GenericImageView::Pixel">Pixel</a></h4></section></summary><div class="docblock"><p>Returns the pixel located at (x, y). Indexed from top left.</p>
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
<p>Panics if <code>(x, y)</code> is out of bounds.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.width" class="method"><a class="src rightside" href="../src/image/image.rs.html#835-838">Source</a><h4 class="code-header">fn <a href="#method.width" class="fn">width</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>The width of this image.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.height" class="method"><a class="src rightside" href="../src/image/image.rs.html#841-844">Source</a><h4 class="code-header">fn <a href="#method.height" class="fn">height</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a></h4></section></summary><div class="docblock"><p>The height of this image.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.in_bounds" class="method"><a class="src rightside" href="../src/image/image.rs.html#847-850">Source</a><h4 class="code-header">fn <a href="#method.in_bounds" class="fn">in_bounds</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns true if this x, y coordinate is contained inside the image.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.unsafe_get_pixel" class="method"><a class="src rightside" href="../src/image/image.rs.html#867-869">Source</a><h4 class="code-header">unsafe fn <a href="#method.unsafe_get_pixel" class="fn">unsafe_get_pixel</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; Self::<a class="associatedtype" href="trait.GenericImageView.html#associatedtype.Pixel" title="type image::GenericImageView::Pixel">Pixel</a></h4></section></summary><div class="docblock"><p>Returns the pixel located at (x, y). Indexed from top left.</p>
<p>This function can be implemented in a way that ignores bounds checking.</p>
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
<p>The coordinates must be <a href="#method.in_bounds"><code>in_bounds</code></a> of the image.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.pixels" class="method"><a class="src rightside" href="../src/image/image.rs.html#874-887">Source</a><h4 class="code-header">fn <a href="#method.pixels" class="fn">pixels</a>(&amp;self) -&gt; <a class="struct" href="struct.Pixels.html" title="struct image::Pixels">Pixels</a>&lt;'_, Self&gt; <a href="#" class="tooltip" data-notable-ty="Pixels&lt;&#39;_, Self&gt;"></a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns an Iterator over the pixels of this image.
The iterator yields the coordinates of each pixel
along with their value</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.view" class="method"><a class="src rightside" href="../src/image/image.rs.html#892-899">Source</a><h4 class="code-header">fn <a href="#method.view" class="fn">view</a>(&amp;self, x: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, y: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, width: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>, height: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -&gt; <a class="struct" href="struct.SubImage.html" title="struct image::SubImage">SubImage</a>&lt;&amp;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns a subimage that is an immutable view into this image.
You can use <a href="trait.GenericImage.html#method.sub_image" title="method image::GenericImage::sub_image"><code>GenericImage::sub_image</code></a> if you need a mutable view instead.
The coordinates set the position of the top left corner of the view.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-GenericImageView-for-DynamicImage" class="impl"><a class="src rightside" href="../src/image/dynimage.rs.html#1037-1047">Source</a><a href="#impl-GenericImageView-for-DynamicImage" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.GenericImageView.html" title="trait image::GenericImageView">GenericImageView</a> for <a class="enum" href="enum.DynamicImage.html" title="enum image::DynamicImage">DynamicImage</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Pixel-1" class="associatedtype trait-impl"><a class="src rightside" href="../src/image/dynimage.rs.html#1038">Source</a><a href="#associatedtype.Pixel-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a> = <a class="struct" href="struct.Rgba.html" title="struct image::Rgba">Rgba</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u8.html">u8</a>&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-GenericImageView-for-View%3CBuffer,+P%3E" class="impl"><a class="src rightside" href="../src/image/flat.rs.html#1396-1427">Source</a><a href="#impl-GenericImageView-for-View%3CBuffer,+P%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Buffer, P: <a class="trait" href="trait.Pixel.html" title="trait image::Pixel">Pixel</a>&gt; <a class="trait" href="trait.GenericImageView.html" title="trait image::GenericImageView">GenericImageView</a> for <a class="struct" href="flat/struct.View.html" title="struct image::flat::View">View</a>&lt;Buffer, P&gt;<div class="where">where
Buffer: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;[P::<a class="associatedtype" href="trait.Pixel.html#associatedtype.Subpixel" title="type image::Pixel::Subpixel">Subpixel</a>]&gt;,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Pixel-2" class="associatedtype trait-impl"><a class="src rightside" href="../src/image/flat.rs.html#1400">Source</a><a href="#associatedtype.Pixel-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a> = P</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-GenericImageView-for-ViewMut%3CBuffer,+P%3E" class="impl"><a class="src rightside" href="../src/image/flat.rs.html#1429-1460">Source</a><a href="#impl-GenericImageView-for-ViewMut%3CBuffer,+P%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Buffer, P: <a class="trait" href="trait.Pixel.html" title="trait image::Pixel">Pixel</a>&gt; <a class="trait" href="trait.GenericImageView.html" title="trait image::GenericImageView">GenericImageView</a> for <a class="struct" href="flat/struct.ViewMut.html" title="struct image::flat::ViewMut">ViewMut</a>&lt;Buffer, P&gt;<div class="where">where
Buffer: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a>&lt;[P::<a class="associatedtype" href="trait.Pixel.html#associatedtype.Subpixel" title="type image::Pixel::Subpixel">Subpixel</a>]&gt; + <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;[P::<a class="associatedtype" href="trait.Pixel.html#associatedtype.Subpixel" title="type image::Pixel::Subpixel">Subpixel</a>]&gt;,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Pixel-3" class="associatedtype trait-impl"><a class="src rightside" href="../src/image/flat.rs.html#1433">Source</a><a href="#associatedtype.Pixel-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a> = P</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-GenericImageView-for-ImageBuffer%3CP,+Container%3E" class="impl"><a class="src rightside" href="../src/image/buffer.rs.html#1168-1189">Source</a><a href="#impl-GenericImageView-for-ImageBuffer%3CP,+Container%3E" class="anchor">§</a><h3 class="code-header">impl&lt;P, Container&gt; <a class="trait" href="trait.GenericImageView.html" title="trait image::GenericImageView">GenericImageView</a> for <a class="struct" href="struct.ImageBuffer.html" title="struct image::ImageBuffer">ImageBuffer</a>&lt;P, Container&gt;<div class="where">where
P: <a class="trait" href="trait.Pixel.html" title="trait image::Pixel">Pixel</a>,
Container: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = [P::<a class="associatedtype" href="trait.Pixel.html#associatedtype.Subpixel" title="type image::Pixel::Subpixel">Subpixel</a>]&gt; + <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Pixel-4" class="associatedtype trait-impl"><a class="src rightside" href="../src/image/buffer.rs.html#1173">Source</a><a href="#associatedtype.Pixel-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Pixel" class="associatedtype">Pixel</a> = P</h4></section></div></details></div><script src="../trait.impl/image/image/trait.GenericImageView.js" async></script><script type="text/json" id="notable-traits-data">{"Pixels<'_, Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Pixels.html\" title=\"struct image::Pixels\">Pixels</a>&lt;'a, I&gt;</code></h3><pre><code><div class=\"where\">impl&lt;'a, I: <a class=\"trait\" href=\"trait.GenericImageView.html\" title=\"trait image::GenericImageView\">GenericImageView</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.Pixels.html\" title=\"struct image::Pixels\">Pixels</a>&lt;'a, I&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.84.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = (<a class=\"primitive\" href=\"https://doc.rust-lang.org/1.84.0/std/primitive.u32.html\">u32</a>, <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.84.0/std/primitive.u32.html\">u32</a>, I::<a class=\"associatedtype\" href=\"trait.GenericImageView.html#associatedtype.Pixel\" title=\"type image::GenericImageView::Pixel\">Pixel</a>);</div>"}</script></section></div></main></body></html>