fn encode_bits(&mut self, bits: u32, bits_length: u8, x: u32, y: u32){
        // We don't know if host image is going to have an alpha channel or not. So
        // we must implement both cases.
        if let Some(contained_image) = self.image.as_mut_rgba8() {
            let pixel = contained_image.get_pixel_mut(x, y);
            let modified_pixel_bytes = ContainerImage::overwrite_pixel(&pixel.data[..3], bits, bits_length);
            *pixel = image::Rgba([modified_pixel_bytes[0],
                modified_pixel_bytes[1],
                modified_pixel_bytes[2],
                pixel[3]]); // We keep original Alpha channel.
        } else {
            let contained_image = self.image.as_mut_rgb8()
                .expect("Something wrong happened when accessing to inner image to encode data");
            let pixel = contained_image.get_pixel_mut(x, y);
            let modified_pixel_bytes = ContainerImage::overwrite_pixel(&pixel.data[..3], bits, bits_length);
            *pixel = image::Rgb([modified_pixel_bytes[0],
                modified_pixel_bytes[1],
                modified_pixel_bytes[2]]);
        }
    }
/// Encode given bits at pixel defined by x and y coordinates.
///
/// # Parameters:
/// * bits: Data to be hidden.
/// * bits_length: How many bits at bits parameter are actually data to be hidden.
/// * x: X coordinate of pixel where data is going to be hidden.
/// * y: Y coordinate of pixel where data is going to be hidden.
Encode given bits at pixel defined by x and y coordinates.
Encode given bits at pixel defined by x and y coordinates .
fn encode_bits(&mut self, bits: u32, bits_length: u8, x: u32, y: u32){
        // We don't know if host image is going to have an alpha channel or not. So
        // we must implement both cases.
        if let Some(contained_image) = self.image.as_mut_rgba8() {
            let pixel = contained_image.get_pixel_mut(x, y);
            let modified_pixel_bytes = ContainerImage::overwrite_pixel(&pixel.data[..3], bits, bits_length);
            *pixel = image::Rgba([modified_pixel_bytes[0],
                modified_pixel_bytes[1],
                modified_pixel_bytes[2],
                pixel[3]]); // We keep original Alpha channel.
        } else {
            let contained_image = self.image.as_mut_rgb8()
                .expect("Something wrong happened when accessing to inner image to encode data");
            let pixel = contained_image.get_pixel_mut(x, y);
            let modified_pixel_bytes = ContainerImage::overwrite_pixel(&pixel.data[..3], bits, bits_length);
            *pixel = image::Rgb([modified_pixel_bytes[0],
                modified_pixel_bytes[1],
                modified_pixel_bytes[2]]);
        }
    }
fn encode_bits ( & mut self , bits : u32 , bits_length : u8 , x : u32 , y : u32 ) { // We don't know if host image is going to have an alpha channel or not. So // we must implement both cases. if let Some ( contained_image ) = self . image . as_mut_rgba8 ( ) { let pixel = contained_image . get_pixel_mut ( x , y ) ; let modified_pixel_bytes = ContainerImage :: overwrite_pixel ( & pixel . data [ .. 3 ] , bits , bits_length ) ; * pixel = image :: Rgba ( [ modified_pixel_bytes [ 0 ] , modified_pixel_bytes [ 1 ] , modified_pixel_bytes [ 2 ] , pixel [ 3 ] ] ) ; // We keep original Alpha channel. } else { let contained_image = self . image . as_mut_rgb8 ( ) . expect ( " " ) ; let pixel = contained_image . get_pixel_mut ( x , y ) ; let modified_pixel_bytes = ContainerImage :: overwrite_pixel ( & pixel . data [ .. 3 ] , bits , bits_length ) ; * pixel = image :: Rgb ( [ modified_pixel_bytes [ 0 ] , modified_pixel_bytes [ 1 ] , modified_pixel_bytes [ 2 ] ] ) ; } }
Encode given bits at pixel defined by x and y coordinates.
Encode given bits at pixel defined by x and y coordinates .
&mut self
bits
u32
bits_length
u8
x
u32
y
u32
&mut self
bits
u32
bits_length
u8
x
u32
y
u32
parameters:
Data to be hidden.
bits_length: How many bits at bits parameter are actually data to be hidden.
x: X coordinate of pixel where data is going to be hidden.
y: Y coordinate of pixel where data is going to be hidden.
Data to be hidden . bits_length : How many bits at bits parameter are actually data to be hidden . x : X coordinate of pixel where data is going to be hidden . y : Y coordinate of pixel where data is going to be hidden .