[−][src]Struct rustbitmap::bitmap::image::BitMap
In memory representation of a bitmap allowing for easier editing
Methods
impl BitMap
[src]
This block deals with constructors, and getters and setters
pub fn read(filename: &str) -> Result<BitMap, String>
[src]
Create a bitmap by reading in a .bmp file
Fails if filename doesn't end with ".bmp"
pub fn new(width: u32, height: u32) -> BitMap
[src]
Create a new bitmap image in memory
Fill all the pixels as white
pub fn create(
width: u32,
height: u32,
pixels: Vec<Rgba>
) -> Result<BitMap, &'static str>
[src]
width: u32,
height: u32,
pixels: Vec<Rgba>
) -> Result<BitMap, &'static str>
Create a new image from a list of pixels
pub fn get_pixel(&self, x: u32, y: u32) -> Option<&Rgba>
[src]
Get a pixel at a specific x and y coordinate
pub fn get_pixels(&self) -> &Vec<Rgba>
[src]
Get a reference to the collection of all the pixels inside of the image
pub fn get_width(&self) -> u32
[src]
Get the width of the image
pub fn get_height(&self) -> u32
[src]
Get the height of the image
pub fn get_size(&self) -> u32
[src]
Get the area of the image in pixels
pub fn get_estimated_file_size_in_bytes(&self) -> u32
[src]
Get the estimated file size in bytes
pub fn get_filename(&self) -> Option<&String>
[src]
Get a reference to the file name of the bitmap if it exists
pub fn get_all_unique_colors(&self) -> Vec<Rgba>
[src]
Get all the unique colors from pixels, remove any duplicates
pub fn is_image_transparent(&self) -> bool
[src]
Check if there is at least one pixel that it translucent
impl BitMap
[src]
This block deals with saving the image
pub fn save(&self) -> Result<(), String>
[src]
Save the image to its original location
Fail if no original location is linked to the current bitmap
pub fn save_as(&self, filename: &str) -> Result<(), String>
[src]
Save the image to a new location on disk
pub fn simplify_and_save(&self) -> Result<(), String>
[src]
Analyze the currently recorded pixels and try and find the lowest bit count possible to save the images at.
The bit depth will be: if there are at most 2 colors present, 2 bit if there are at most 16 colors present, 4 bit if there are at most 256 colors present, 8 bit if there are more then 256 colors and all alphas are 100, 24 bit if there are more then 256 colors and at least one alpha is not 100, 32 bit
pub fn simplify_and_save_as(&self, filename: &str) -> Result<(), String>
[src]
Analyze the currently recorded pixels and try and find the lowest bit count possible to save the images at.
The bit depth will be: if there are at most 2 colors present, 2 bit if there are at most 16 colors present, 4 bit if there are at most 256 colors present, 8 bit if there are more then 256 colors and all alphas are 100, 24 bit if there are more then 256 colors and at least one alpha is not 100, 32 bit
impl BitMap
[src]
This block deals with creating a new bitmap from an existing one and manipulating bit maps using other bitmaps
pub fn crop(
&self,
from_x: u32,
from_y: u32,
to_x: u32,
to_y: u32
) -> Result<BitMap, &'static str>
[src]
&self,
from_x: u32,
from_y: u32,
to_x: u32,
to_y: u32
) -> Result<BitMap, &'static str>
Crop a given area of the current image
@param {u32} starting x position @param {u32} starting y position @param {u32} ending x position @param {u32} ending y position
@exception {&'static str} error message if the starting x and ending x or starting y and ending y is out of the image with height or width, throw an error
pub fn paste(
&mut self,
bitmap: &BitMap,
start_at_x: u32,
start_at_y: u32
) -> Result<(), &'static str>
[src]
&mut self,
bitmap: &BitMap,
start_at_x: u32,
start_at_y: u32
) -> Result<(), &'static str>
Paste and entire bitmap into the current bitmap.
impl BitMap
[src]
This block deals with coloring the image
pub fn set_pixel(
&mut self,
x: u32,
y: u32,
color: Rgba
) -> Result<(), &'static str>
[src]
&mut self,
x: u32,
y: u32,
color: Rgba
) -> Result<(), &'static str>
Set the color of a pixel
@param {u32} x position @param {u32} y position @param {Rgba} color to set pixel
pub fn color_to_gray(&mut self)
[src]
Convert image from a colored image to gray
pub fn replace_all_color(&mut self, from: Rgba, to: Rgba)
[src]
Find all the pixels that are the same as the from color and convert them all to the "to" color.
@param {Rgba} from color @param {Rgba} to color
pub fn fill_region(
&mut self,
x: u32,
y: u32,
color: Rgba
) -> Result<(), &'static str>
[src]
&mut self,
x: u32,
y: u32,
color: Rgba
) -> Result<(), &'static str>
Fill a region of an image with a color. The only colors that get changed are those that are the same as the pixel found at the given x and y value
@param {u32} x position @param {u32} y position @param {Rgba} color to use to replace the other color
impl BitMap
[src]
This block is only meant for resizing images using one of the 3 (so far only 2 implemented) algorithms (nearest neighbor, bilinear, bicubic) as well as rotating the image left or right by 90 degrees
pub fn fast_resize_by(&mut self, factor: f32) -> Result<(), &'static str>
[src]
Resize the current image by using nearest neighbor algorithm. Scale image to image size * the factor
pub fn fast_resize_to(&mut self, width: u32, height: u32)
[src]
Resize the current image by using nearest neighbor algorithm. Scale image to specified width and height
pub fn resize_by(&mut self, factor: f32) -> Result<(), &'static str>
[src]
Resize the current image by using bilinear interpolation algorithm. Scale image to image size * the factor
pub fn resize_to(&mut self, width: u32, height: u32)
[src]
Resize the current image by using bilinear interpolation algorithm. Scale image to specified width and height
pub fn slow_resize_by(&mut self, factor: f32) -> Result<(), &'static str>
[src]
Resize the current image by using bicubic interpolation algorithm. Scale image to image size * the factor
pub fn slow_resize_to(&mut self, width: u32, height: u32)
[src]
Resize the current image by using bicubic interpolation algorithm. Scale image to specified width and height
pub fn slow_resize(&mut self, width: u32, height: u32)
[src]
Resize the current image by using bicubic interpolation algorithm
pub fn rotate_right(&mut self)
[src]
Rotate the entire image right by 90 degrees
pub fn rotate_left(&mut self)
[src]
Rotate the entire image left by 90 degrees
Trait Implementations
impl PartialEq<BitMap> for BitMap
[src]
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Display for BitMap
[src]
impl Debug for BitMap
[src]
Auto Trait Implementations
impl Unpin for BitMap
impl Sync for BitMap
impl Send for BitMap
impl UnwindSafe for BitMap
impl RefUnwindSafe for BitMap
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,