stuff-from-scratch/test/image/TestPngWriter.cpp

27 lines
591 B
C++
Raw Normal View History

2022-01-01 18:46:31 +00:00
#include "Image.h"
#include "PngWriter.h"
2022-11-21 17:45:12 +00:00
#include "ImagePrimitives.h"
2022-01-01 18:46:31 +00:00
2022-05-18 07:42:44 +00:00
#include <iostream>
2022-01-01 18:46:31 +00:00
int main()
{
unsigned width = 200;
unsigned height = 200;
unsigned numChannels = 3;
auto image = Image<unsigned char>::Create(width, height);
image->setNumChannels(numChannels);
2022-01-01 18:46:31 +00:00
std::vector<unsigned char> data(image->getBytesPerRow()*height, 0);
2022-11-21 17:45:12 +00:00
ImagePrimitives::drawAlternatingStrips(data, width,height, numChannels, image->getBytesPerRow());
image->setData(data);
2022-01-01 18:46:31 +00:00
PngWriter writer;
2022-11-21 17:45:12 +00:00
writer.setPath("test.png");
writer.write(image);
2022-01-01 18:46:31 +00:00
return 0;
}