stuff-from-scratch/test/image/TestPngWriter.cpp
2022-11-21 17:45:12 +00:00

26 lines
591 B
C++

#include "Image.h"
#include "PngWriter.h"
#include "ImagePrimitives.h"
#include <iostream>
int main()
{
unsigned width = 200;
unsigned height = 200;
unsigned numChannels = 3;
auto image = Image<unsigned char>::Create(width, height);
image->setNumChannels(numChannels);
std::vector<unsigned char> data(image->getBytesPerRow()*height, 0);
ImagePrimitives::drawAlternatingStrips(data, width,height, numChannels, image->getBytesPerRow());
image->setData(data);
PngWriter writer;
writer.setPath("test.png");
writer.write(image);
return 0;
}