53 lines
1.7 KiB
C
Executable File
53 lines
1.7 KiB
C
Executable File
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "lib/image.h"
|
|
#include "lib/image_ppm.h"
|
|
#include "libcproject/libcproject.h"
|
|
|
|
int main() {
|
|
printf("Generating images...\n");
|
|
size_t images_count = 0;
|
|
for (size_t red = 0; red < 256; red += 51) {
|
|
for (size_t green = 0; green < 256; green += 51) {
|
|
for (size_t blue = 0; blue < 256; blue += 51) {
|
|
struct image* image = image_initialization(100, 100);
|
|
for (size_t row = 0; row < image->height; row++) {
|
|
for (size_t column = 0; column < image->width; column++) {
|
|
image->pixels[row][column].red = red;
|
|
image->pixels[row][column].green = green;
|
|
image->pixels[row][column].blue = blue;
|
|
}
|
|
}
|
|
string_t red_string = convert_number_to_string((long long)red);
|
|
string_t green_string = convert_number_to_string((long long)green);
|
|
string_t blue_string = convert_number_to_string((long long)blue);
|
|
|
|
string_t path = string_copy("./assets/");
|
|
string_concatenate(&path, "image-red-");
|
|
string_concatenate(&path, red_string);
|
|
string_concatenate(&path, "-green-");
|
|
string_concatenate(&path, green_string);
|
|
string_concatenate(&path, "-blue-");
|
|
string_concatenate(&path, blue_string);
|
|
string_concatenate(&path, ".ppm");
|
|
free(red_string);
|
|
free(green_string);
|
|
free(blue_string);
|
|
|
|
off_t file_size = 0;
|
|
byte_t* image_ppm = image_to_ppm_binary(image, &file_size);
|
|
filesystem_write(path, image_ppm, file_size);
|
|
images_count += 1;
|
|
|
|
image_free(image);
|
|
free(path);
|
|
free(image_ppm);
|
|
}
|
|
}
|
|
}
|
|
printf("Generated %zu images in `./assets`.\n", images_count);
|
|
return EXIT_SUCCESS;
|
|
}
|