Last active
August 29, 2015 14:22
-
-
Save ranisalt/db9a3b410d37f418f59e to your computer and use it in GitHub Desktop.
Buggy file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lodepng/lodepng.h" | |
#include "iomap.h" | |
bool IOMap::exportPNG(const Map& map, std::string filename) | |
{ | |
uint32_t size = static_cast<uint32_t>(map._height) * static_cast<uint32_t>(map._width); | |
std::vector<uint8_t> bytes(size * 4); | |
for (uint16_t x = 0; x < map._height; ++x) { | |
for (uint16_t y = 0; y < map._width; ++y) { | |
auto index = map.index(x, y); | |
bytes[index] = 255; | |
bytes[index + 1] = 0; | |
bytes[index + 2] = 0; | |
bytes[index + 3] = 255; | |
} | |
} | |
if (lodepng::encode(filename, bytes, map._height, map._width) != 0) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment