summaryrefslogtreecommitdiff
path: root/test.cpp
blob: bc2366c77d7e19bac30bb74a6e634261dc8f1797 (plain)
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 <iostream>
#include <string>
#include "libpng_wrapper.hpp"
using namespace std;

void test_png() {
  png test_image("test_png.png", 500, 500);
  uint32_t w = test_image.width();
  uint32_t h = test_image.height();

  uint32_t square_w = w / 2;
  uint32_t square_h = h / 2;
  uint32_t square_x = square_w;
  uint32_t square_y = square_h;

  for(uint32_t y = 0; y < h; y++) {
    for(uint32_t x = 0; x < w; x++) {
      if((x < (w / 2)) && (y < (h / 2))) {
        test_image.set_pixel(x, y, 255, 0, 0);
      }
      else if((x > (w / 2)) && (y < (h / 2))) {
        test_image.set_pixel(x, y, 0, 255, 0);
      }
      else if((x < (w / 2)) && (y > (h / 2))) {
        test_image.set_pixel(x, y, 0, 0, 255);
      }
      else if((x > (w / 2)) && (y > (h / 2))) {
        test_image.set_pixel(x, y, 
            (255 / square_w) * (x - square_x), 
            (255 / square_h) * (y - square_y), 
            (255 / square_w) * (square_x - x));
      }
    }
  }
}