#include "Image.h" #include "Color.h" template Image::Image(unsigned width, unsigned height) : mWidth(width), mHeight(height) { } template Image::~Image() { } template void Image::initialize() { mData = std::vector(getBytesPerRow()*mHeight, 10); } template void Image::setDataItem(std::size_t index, T item) { if(index >= mData.size()) { return; } mData[index] = item; } template void Image::setPixelValue(unsigned idx, unsigned jdx, const Color& color) { if (mData.empty()) { initialize(); } mData[jdx*getBytesPerRow() + idx*3] = static_cast(color.getR()); mData[jdx*getBytesPerRow() + idx*3 + 1] = static_cast(color.getG()); mData[jdx*getBytesPerRow() + idx*3 + 2] = static_cast(color.getB()); } template std::unique_ptr > Image::Create(unsigned width, unsigned height) { return std::make_unique >(width, height); } template unsigned Image::getBytesPerRow() const { const auto bitsPerEntry = mBitDepth <= 8 ? 1 : 2; return mWidth * mNumChannels *bitsPerEntry; } template unsigned Image::getWidth() const { return mWidth; } template unsigned Image::getHeight() const { return mHeight; } template unsigned Image::getBitDepth() const { return mBitDepth; } template T Image::getByte(unsigned idx, unsigned jdx) const { return mData[jdx*getBytesPerRow() + idx]; } template unsigned Image::getNumChannels() const { return mNumChannels; } template void Image::setData(const std::vector& data) { mData = data; } template void Image::setWidth(unsigned width) { mWidth = width; } template void Image::setHeight(unsigned height) { mHeight = height; } template void Image::setBitDepth(unsigned bitDepth) { mBitDepth = bitDepth; } template void Image::setNumChannels(unsigned numChannels) { mNumChannels = numChannels; } template class Image; //template class Image;