[−][src]Function photon::channels::alter_channel
pub fn alter_channel(img: &mut PhotonImage, channel: usize, amt: i16)
Alter a select channel by incrementing or decrementing its value by a constant.
Arguments
img
- A PhotonImage.channel
- The channel you wish to alter, it should be either 0, 1 or 2, representing R, G, or B respectively. (O=Red, 1=Green, 2=Blue)amount
- The amount to increment/decrement the channel's value by for that pixel. A positive value will increment/decrement the channel's value, a negative value will decrement the channel's value.
Example
// For example, to increase the Red channel for all pixels by 10: use photon::channels; let img = photon::open_image("img.jpg"); photon::channels::alter_channel(&mut img, 0, 10); // Write the contents of this image in JPG format. photon::helpers::save_image(img, "new_image.png");
Adds a constant to a select R, G, or B channel's value.
Decrease a channel's value
// For example, to decrease the Green channel for all pixels by 20:
use photon::channels; photon::channels::alter_channel(&mut img, 1, -20);
Note: Note the use of a minus symbol when decreasing the channel.