Add geometry handling.

This commit is contained in:
jmsgrogan 2022-05-15 14:58:31 +01:00
parent 9c116b1efd
commit c1389218f2
37 changed files with 294 additions and 278 deletions

View file

@ -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);