1
0
Fork 0

source/Graphics: do not prefix standard c functions with "std::", also include the right files.

This commit is contained in:
Henrik Hautakoski 2019-05-31 20:14:47 +02:00
parent ba11d5002b
commit f3a3a6aa4d
2 changed files with 16 additions and 14 deletions

View file

@ -1,7 +1,8 @@
#include "ImageLoader.h" #include <cstring>
#include <Spectre/System/Log.h> #include <Spectre/System/Log.h>
#include <Spectre/Graphics/Image.h> #include <Spectre/Graphics/Image.h>
#include "ImageLoader.h"
static ImageLoader _loader; static ImageLoader _loader;
@ -196,7 +197,7 @@ void Image::setPixels(const void *pixels)
unsigned int size = m_size.y * getStride(); unsigned int size = m_size.y * getStride();
m_pixels.resize(size); m_pixels.resize(size);
std::memcpy(&m_pixels[0], pixels, m_pixels.size()); memcpy(&m_pixels[0], pixels, m_pixels.size());
} }
const unsigned char* Image::getPixels() const const unsigned char* Image::getPixels() const

View file

@ -16,8 +16,9 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h" #include "stb_image_write.h"
#include <string.h> #include <cstring>
#include <stdio.h> #include <cstdlib>
#include <cstdio>
#include <vector> #include <vector>
bool ImageLoader::loadFromFile(const char *filename, Image& img) bool ImageLoader::loadFromFile(const char *filename, Image& img)
@ -42,7 +43,7 @@ bool ImageLoader::loadFromFile(const char *filename, Image& img)
} }
log("ImageLoader: could not open file '%s'. Reason: %s", log("ImageLoader: could not open file '%s'. Reason: %s",
filename, std::strerror(errno)); filename, strerror(errno));
return false; return false;
} }
@ -120,7 +121,7 @@ bool ImageLoader::encodePNG(const Image& img, std::vector<unsigned char>& data)
if (buf && buf_len > 0) { if (buf && buf_len > 0) {
data.resize(buf_len); data.resize(buf_len);
std::memcpy(&data[0], buf, buf_len); memcpy(&data[0], buf, buf_len);
STBIW_FREE(buf); STBIW_FREE(buf);
return true; return true;