netatmo-algo/src/frame.cpp

36 lines
775 B
C++

#include "frame.h"
#include <cstring>
Frame::Frame(uint32_t width, uint32_t height) : width(width), height(height) {
data = new Pixel[width * height];
}
Frame::Frame(const Frame& other) : Frame(other.width, other.height) {
std::memcpy(data, other.data, width * height);
}
Frame& Frame::operator=(const Frame& other) {
width = other.width;
height = other.height;
delete[] data;
data = new Pixel[width * height];
std::memcpy(data, other.data, width * height);
return *this;
}
Frame::Frame(Frame&& other) {
width = other.width;
height = other.height;
data = other.data;
other.data = nullptr;
}
Frame::~Frame() {
delete[] data;
}
void Frame::fill(uint8_t p) {
std::memset(data, p, width * height * sizeof(Pixel));
}