[−][src]Struct imagequant::Image
Describes image dimensions for the library.
Implementations
impl<'bitmap> Image<'bitmap>
[src]
pub fn new(
attr: &Attributes,
bitmap: &'bitmap [RGBA],
width: usize,
height: usize,
gamma: f64
) -> Result<Self, liq_error>
[src]
attr: &Attributes,
bitmap: &'bitmap [RGBA],
width: usize,
height: usize,
gamma: f64
) -> Result<Self, liq_error>
Describe dimensions of a slice of RGBA pixels.
bitmap
must be either &[u8]
or a slice with one element per pixel (&[RGBA]
).
Use 0.
for gamma if the image is sRGB (most images are).
pub fn new_unsafe_fn<CustomData: Send + Sync + 'bitmap>(
attr: &Attributes,
convert_row_fn: ConvertRowUnsafeFn<CustomData>,
user_data: *mut CustomData,
width: usize,
height: usize,
gamma: f64
) -> Result<Self, liq_error>
[src]
attr: &Attributes,
convert_row_fn: ConvertRowUnsafeFn<CustomData>,
user_data: *mut CustomData,
width: usize,
height: usize,
gamma: f64
) -> Result<Self, liq_error>
Generate rows on demand using a callback function.
The callback function must be cheap (e.g. just byte-swap pixels). It will be called multiple times per row. May be called in any order from any thread.
The user data must be compatible with a primitive pointer
(i.e. not a slice, not a Trait object. Box
it if you must).
pub fn new_stride(
attr: &Attributes,
bitmap: &'bitmap [RGBA],
width: usize,
height: usize,
stride: usize,
gamma: f64
) -> Result<Self, liq_error>
[src]
attr: &Attributes,
bitmap: &'bitmap [RGBA],
width: usize,
height: usize,
stride: usize,
gamma: f64
) -> Result<Self, liq_error>
Stride is in pixels. Allows defining regions of larger images or images with padding without copying.
pub fn new_stride_copy(
attr: &Attributes,
bitmap: &[RGBA],
width: usize,
height: usize,
stride: usize,
gamma: f64
) -> Result<Image<'static>, liq_error>
[src]
attr: &Attributes,
bitmap: &[RGBA],
width: usize,
height: usize,
stride: usize,
gamma: f64
) -> Result<Image<'static>, liq_error>
Create new image by copying bitmap
to an internal buffer, so that it makes a self-contained type.
pub fn width(&self) -> usize
[src]
Width of the image in pixels
pub fn height(&self) -> usize
[src]
Height of the image in pixels
pub fn add_fixed_color(&mut self, color: liq_color) -> liq_error
[src]
Reserves a color in the output palette created from this image. It behaves as if the given color was used in the image and was very important.
RGB values of liq_color are assumed to have the same gamma as the image.
It must be called before the image is quantized.
Returns error if more than 256 colors are added. If image is quantized to fewer colors than the number of fixed colors added, then excess fixed colors will be ignored.
pub fn set_background<'own, 'bg: 'own>(
&'own mut self,
background: Image<'bg>
) -> Result<(), liq_error>
[src]
&'own mut self,
background: Image<'bg>
) -> Result<(), liq_error>
Remap pixels assuming they will be displayed on this background.
Pixels that match the background color will be made transparent if there's a fully transparent color available in the palette.
The background image's pixels must outlive this image
pub fn set_importance_map(&mut self, map: &[u8]) -> Result<(), liq_error>
[src]
Set which pixels are more important (and more likely to get a palette entry)
The map must be width
×height
pixels large. Higher numbers = more important.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Image<'a>
[src]
impl<'a> !Sync for Image<'a>
[src]
impl<'a> Unpin for Image<'a>
[src]
impl<'a> UnwindSafe for Image<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,