qrcode::render

Struct Renderer

Source
pub struct Renderer<'a, P: Pixel> { /* private fields */ }
Expand description

A QR code renderer. This is a builder type which converts a bool-vector into an image.

Implementations§

Source§

impl<'a, P: Pixel> Renderer<'a, P>

Source

pub fn new( content: &'a [Color], modules_count: usize, quiet_zone: u32, ) -> Renderer<'a, P>

Creates a new renderer.

Source

pub fn dark_color(&mut self, color: P) -> &mut Self

Sets color of a dark module. Default is opaque black.

Source

pub fn light_color(&mut self, color: P) -> &mut Self

Sets color of a light module. Default is opaque white.

Source

pub fn quiet_zone(&mut self, has_quiet_zone: bool) -> &mut Self

Whether to include the quiet zone in the generated image.

Source

pub fn module_size(&mut self, width: u32) -> &mut Self

👎Deprecated since 0.4.0: use .module_dimensions(width, width) instead

Sets the size of each module in pixels. Default is 8px.

Source

pub fn module_dimensions(&mut self, width: u32, height: u32) -> &mut Self

Sets the size of each module in pixels. Default is 8×8.

Source

pub fn min_width(&mut self, width: u32) -> &mut Self

👎Deprecated since 0.4.0: use .min_dimensions(width, width) instead
Source

pub fn min_dimensions(&mut self, width: u32, height: u32) -> &mut Self

Sets the minimum total image size in pixels, including the quiet zone if applicable. The renderer will try to find the dimension as small as possible, such that each module in the QR code has uniform size (no distortion).

For instance, a version 1 QR code has 19 modules across including the quiet zone. If we request an image of size ≥200×200, we get that each module’s size should be 11×11, so the actual image size will be 209×209.

Source

pub fn max_dimensions(&mut self, width: u32, height: u32) -> &mut Self

Sets the maximum total image size in pixels, including the quiet zone if applicable. The renderer will try to find the dimension as large as possible, such that each module in the QR code has uniform size (no distortion).

For instance, a version 1 QR code has 19 modules across including the quiet zone. If we request an image of size ≤200×200, we get that each module’s size should be 10×10, so the actual image size will be 190×190.

The module size is at least 1×1, so if the restriction is too small, the final image can be larger than the input.

Source

pub fn to_image(&self) -> P::Image

👎Deprecated since 0.4.0: renamed to .build() to de-emphasize the image connection

Renders the QR code into an image.

Source

pub fn build(&self) -> P::Image

Renders the QR code into an image.

Auto Trait Implementations§

§

impl<'a, P> Freeze for Renderer<'a, P>
where P: Freeze,

§

impl<'a, P> RefUnwindSafe for Renderer<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for Renderer<'a, P>
where P: Send,

§

impl<'a, P> Sync for Renderer<'a, P>
where P: Sync,

§

impl<'a, P> Unpin for Renderer<'a, P>
where P: Unpin,

§

impl<'a, P> UnwindSafe for Renderer<'a, P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.