Add geometry handling.
This commit is contained in:
parent
9c116b1efd
commit
c1389218f2
37 changed files with 294 additions and 278 deletions
|
@ -16,6 +16,6 @@ target_include_directories(image PUBLIC
|
|||
set_target_properties( image PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
target_link_libraries( image PUBLIC PNG::PNG)
|
||||
target_link_libraries( image PUBLIC PNG::PNG core)
|
||||
|
||||
set_property(TARGET image PROPERTY FOLDER src)
|
|
@ -7,6 +7,23 @@ Image::Image(unsigned width, unsigned height)
|
|||
|
||||
}
|
||||
|
||||
void Image::Initialize()
|
||||
{
|
||||
mData = std::vector<unsigned char>(GetBytesPerRow()*mHeight, 0);
|
||||
}
|
||||
|
||||
void Image::SetPixelValue(unsigned idx, unsigned jdx, const Color& color)
|
||||
{
|
||||
if (mData.empty())
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
mData[jdx*GetBytesPerRow() + idx*3] = static_cast<unsigned char>(color.GetR());
|
||||
mData[jdx*GetBytesPerRow() + idx*3 + 1] = static_cast<unsigned char>(color.GetG());
|
||||
mData[jdx*GetBytesPerRow() + idx*3 + 2] = static_cast<unsigned char>(color.GetB());
|
||||
}
|
||||
|
||||
std::unique_ptr<Image> Image::Create(unsigned width, unsigned height)
|
||||
{
|
||||
return std::make_unique<Image>(width, height);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@ -16,6 +18,9 @@ public:
|
|||
unsigned GetHeight() const;
|
||||
unsigned GetBitDepth() const;
|
||||
unsigned GetNumChannels() const;
|
||||
|
||||
void SetPixelValue(unsigned idx, unsigned jdx, const Color& color);
|
||||
|
||||
unsigned char GetByte(unsigned idx, unsigned jdx) const;
|
||||
|
||||
void SetData(const std::vector<unsigned char>& data);
|
||||
|
@ -25,6 +30,8 @@ public:
|
|||
void SetNumChannels(unsigned numChannels);
|
||||
|
||||
private:
|
||||
void Initialize();
|
||||
|
||||
unsigned mWidth{1};
|
||||
unsigned mHeight{1};
|
||||
unsigned mBitDepth{8};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue