summaryrefslogtreecommitdiff
path: root/applications/init/main.cpp
blob: 06a82038fc07fe4e964143cf0d7808530b394d84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <daguerre/image.hpp>

int main(int, char **) {

  auto fb = daguerre::get_hilbert_framebuffer();

  auto white = daguerre::to_hilbert_color({.r = 255, .g = 255, .b = 255});
  auto gray  = daguerre::to_hilbert_color({.r = 127, .g = 127, .b = 127});

  for (unsigned y = 0; y < fb.get_height(); ++y)
    for (unsigned x = 0; x < fb.get_width(); ++x) {
      uint8_t v = (y / 16) % 2 == (x / 16) % 2;
      fb.get(x, y) = v ? white : gray;
    }

  daguerre::image<daguerre::color24> img;

  std::FILE *file = std::fopen("/assets/burdon.ppm", "r");
  assert(file != 0);
  assert(daguerre::try_load_ppm(file, img));
  std::fclose(file);

  unsigned width =
    img.get_width() < fb.get_width() ? img.get_width() : fb.get_width();
  unsigned height =
    img.get_height() < fb.get_height() ? img.get_height() : fb.get_height();

  unsigned x_off = (fb.get_width() - width) / 2;
  unsigned y_off = (fb.get_height() - height) / 2;

  daguerre::copy_image(img, fb, 0, 0, x_off, y_off, width, height);

  return 0;

}