title | timestamp | author | published | description | tags | |
---|---|---|---|---|---|---|
Create empty image with white background and black borders using Rust |
2023-10-02 03:00:01 -0700 |
szabgab |
true |
The default background is black. We can set the background to any color. This case we set it to white. |
|
When we create an image the default color of each pixel is black as you can see in the empty image example. In this example we just set all the pixels to be white. We could of course set them to any color we would like expressed in RGB - red-green-blue triplets.
After setting all the pixel to white I realized that you won't be able to see the white image on the white background of this page, so I also added two more loops to set the borders of the image to black.
{% include file="examples/create-white-image/src/main.rs" %}
{% include file="examples/create-white-image/Cargo.toml" %}