Welcome to mirror list, hosted at ThFree Co, Russian Federation.

png_decoder_test.cpp « coding_tests « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 74e463853578e10a86eae84d4b6d3ce30cff0274 (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
36
37
38
39
40
41
42
#include "testing/testing.hpp"

#include "std/string.hpp"
#include "std/fstream.hpp"
#include "std/vector.hpp"

void loadFile(vector<unsigned char> & buffer, string const & filename) //designed for loading files from hard disk in an std::vector
{
  ifstream file(filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);

  // get filesize
  std::streamsize size = 0;
  if (file.seekg(0, std::ios::end).good())
    size = file.tellg();
  if (file.seekg(0, std::ios::beg).good())
    size -= file.tellg();

  // read contents of the file into the vector
  if (size > 0)
  {
    buffer.resize((size_t)size);
    file.read((char*)(&buffer[0]), size);
  }
  else
    buffer.clear();
}

UNIT_TEST(PngDecode)
{
//  // load and decode
//  vector<unsigned char> buffer, image;
//  loadFile(buffer, "../../data/font_0.png");
//  unsigned long w, h;
//  int error = DecodePNG(image, w, h, buffer.empty() ? 0 : &buffer[0], (unsigned long)buffer.size());
//
//  // if there's an error, display it
//  TEST_EQUAL(error, 0, ());
//  // the pixels are now in the vector "image", use it as texture, draw it, ...
//  TEST_GREATER(image.size(), 4, ("Image is empty???"));
//  TEST_EQUAL(w, 1024, ());
//  TEST_EQUAL(h, 1024, ());
}