58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class Color;
|
|
|
|
template<typename T>
|
|
class Image
|
|
{
|
|
public:
|
|
Image(unsigned width, unsigned height);
|
|
~Image();
|
|
static std::unique_ptr<Image<T> > Create(unsigned width, unsigned height);
|
|
|
|
unsigned getBytesPerRow() const;
|
|
unsigned getWidth() const;
|
|
unsigned getHeight() const;
|
|
unsigned getBitDepth() const;
|
|
unsigned getNumChannels() const;
|
|
|
|
void setPixelValue(unsigned idx, unsigned jdx, const Color& color);
|
|
|
|
T getByte(unsigned idx, unsigned jdx) const;
|
|
|
|
void setData(const std::vector<T>& data);
|
|
|
|
void setDataItem(std::size_t index, T);
|
|
void setWidth(unsigned width);
|
|
void setHeight(unsigned height);
|
|
void setBitDepth(unsigned bitDepth);
|
|
void setNumChannels(unsigned numChannels);
|
|
|
|
void initialize();
|
|
|
|
const T* getDataPtr() const
|
|
{
|
|
return mData.data();
|
|
}
|
|
|
|
const std::vector<T>& getDataRef() const
|
|
{
|
|
return mData;
|
|
}
|
|
|
|
std::vector<T> getData() const
|
|
{
|
|
return mData;
|
|
}
|
|
|
|
private:
|
|
|
|
unsigned mWidth{1};
|
|
unsigned mHeight{1};
|
|
unsigned mBitDepth{8};
|
|
unsigned mNumChannels{4};
|
|
std::vector<T> mData;
|
|
};
|