Clean up grid.

This commit is contained in:
jmsgrogan 2023-01-16 08:54:45 +00:00
parent d4bb2b2744
commit 3c6756d7a1
27 changed files with 210 additions and 227 deletions

View file

@ -1,19 +1,30 @@
#pragma once
#include "PlatformImage.h"
#include "ImageData.h"
#include <memory>
#include <vector>
class Color;
class AbstractGrid;
template<typename T>
class Grid;
class Image
{
public:
Image(unsigned width, unsigned height, ImageData::Type dataType = ImageData::Type::UCHAR);
enum class DataType
{
UCHAR
};
using Index = std::pair<std::size_t, std::size_t>;
using Indices = std::vector<Index>;
Image(unsigned width, unsigned height, DataType dataType = DataType::UCHAR);
~Image();
static std::unique_ptr<Image> Create(unsigned width, unsigned height, ImageData::Type dataType = ImageData::Type::UCHAR);
static std::unique_ptr<Image> Create(unsigned width, unsigned height, DataType dataType = DataType::UCHAR);
unsigned getBytesPerRow() const;
unsigned getWidth() const;
@ -21,11 +32,15 @@ public:
unsigned getBitDepth() const;
unsigned getNumChannels() const;
ImageData* getData();
unsigned char getAsUnsignedChar(unsigned idx, unsigned jdx) const;
AbstractGrid* getData() const;
template<typename T>
Grid<T>* getDataT() const;
DataType getType() const;
PlatformImage* getPlatformImage();
void setPixelValue(unsigned idx, unsigned jdx, const Color& color);
void setPixelValues(const Indices& indices, const std::vector<Color>& colors);
void setWidth(unsigned width);
void setHeight(unsigned height);
void setBitDepth(unsigned bitDepth);
@ -39,7 +54,7 @@ private:
unsigned mBitDepth{8};
unsigned mNumChannels{4};
ImageData::Type mDataType;
std::unique_ptr<ImageData> mData;
DataType mDataType;
std::unique_ptr<AbstractGrid> mData;
std::unique_ptr<PlatformImage> mPlatformImage;
};