summary refs log tree commit diff stats
path: root/src/util.cpp
blob: f0c39fd875a85af4d90c2ae4caa16b4fe7f68cb6 (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
#include "util.h"

std::string slurp(std::ifstream& in)
{
  std::stringstream sstr;
  sstr << in.rdbuf();
  return sstr.str();
}

void flipImageData(
  unsigned char* data,
  int width,
  int height,
  int comps)
{
  unsigned char* dataCopy = new unsigned char[width * height * comps];
  memcpy(dataCopy, data, width * height * comps);

  int rowSize = width * comps;

  for (int i = 0; i < height; i++)
  {
    memcpy(
      data + (rowSize * i),
      dataCopy + (rowSize * (height - i - 1)),
      rowSize);
  }

  delete[] dataCopy;
}