Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 993 Bytes

create-empty-image-with-white-background.md

File metadata and controls

29 lines (19 loc) · 993 Bytes
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.
image

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.

The source code

{% include file="examples/create-white-image/src/main.rs" %}

The result

The setup

{% include file="examples/create-white-image/Cargo.toml" %}