Add PDF writer.
This commit is contained in:
parent
c05b7b6315
commit
9c116b1efd
72 changed files with 1819 additions and 114 deletions
31
test/image/TestPngWriter.cpp
Normal file
31
test/image/TestPngWriter.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "Image.h"
|
||||
#include "PngWriter.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned width = 200;
|
||||
unsigned height = 200;
|
||||
unsigned numChannels = 3;
|
||||
auto image = Image::Create(width, height);
|
||||
image->SetNumChannels(numChannels);
|
||||
|
||||
std::vector<unsigned char> data(image->GetBytesPerRow()*height, 0);
|
||||
for(unsigned jdx=0;jdx<height;jdx++)
|
||||
{
|
||||
const auto heightOffset = jdx*image->GetBytesPerRow();
|
||||
for(unsigned idx=0;idx<width*numChannels;idx+=numChannels)
|
||||
{
|
||||
const auto index = heightOffset + idx;
|
||||
data[index] = (idx%2 == 0) ? 255*jdx/(height+1) : 0;
|
||||
data[index+1] = 0;
|
||||
data[index+2] = 0;
|
||||
}
|
||||
}
|
||||
image->SetData(data);
|
||||
|
||||
PngWriter writer;
|
||||
writer.SetPath("test.png");
|
||||
writer.Write(image);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue