Clean up Image class.
This commit is contained in:
parent
4bb87de0e6
commit
0d3674faac
30 changed files with 330 additions and 135 deletions
|
@ -1,17 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "PlatformImage.h"
|
||||
#include "ImageData.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class Color;
|
||||
|
||||
template<typename T>
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
Image(unsigned width, unsigned height);
|
||||
Image(unsigned width, unsigned height, ImageData::Type dataType = ImageData::Type::UCHAR);
|
||||
~Image();
|
||||
static std::unique_ptr<Image<T> > Create(unsigned width, unsigned height);
|
||||
static std::unique_ptr<Image> Create(unsigned width, unsigned height, ImageData::Type dataType = ImageData::Type::UCHAR);
|
||||
|
||||
unsigned getBytesPerRow() const;
|
||||
unsigned getWidth() const;
|
||||
|
@ -19,40 +21,25 @@ public:
|
|||
unsigned getBitDepth() const;
|
||||
unsigned getNumChannels() const;
|
||||
|
||||
ImageData* getData();
|
||||
unsigned char getAsUnsignedChar(unsigned idx, unsigned jdx) const;
|
||||
PlatformImage* getPlatformImage() 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:
|
||||
void initialize();
|
||||
|
||||
unsigned mWidth{1};
|
||||
unsigned mHeight{1};
|
||||
unsigned mBitDepth{8};
|
||||
unsigned mNumChannels{4};
|
||||
std::vector<T> mData;
|
||||
|
||||
ImageData::Type mDataType;
|
||||
std::unique_ptr<ImageData> mData;
|
||||
std::unique_ptr<PlatformImage> mPlatformImage;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue