Code: Select all
text
with
newline breaks
![Image](https://user-images.githubusercontent.com/18466811/49865450-dad86200-fdfc-11e8-9a01-d6bd20d89509.jpg)
Is there special handling for newline?
Fedora 28, x64, ImageMagick 6.9.9-38 Q16
Code: Select all
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <strings.h>
#include <limits.h>
#include <string>
#include <sstream>
#include <iostream>
#include <cassert>
using namespace std;
#include <Magick++.h>
int main(int argc, char* const argv[])
{
int ret = 0;
try
{
ostringstream os;
os << "text\nwith\nnewline breaks";
Magick::Image magick(argc == 2 ? argv[1] : "600x400", "blue");
Magick::Image info(Magick::Geometry(magick.columns(), magick.rows()), "grey");
info.borderColor("grey");
info.fontPointsize(28);
info.annotate(os.str(), Magick::Geometry("+10+10"), MagickCore::WestGravity);
info.trim();
info.border();
info.opacity(65535/3.0);
info.transparent("grey");
cout << "composite size=" << info.columns() << "x" << info.rows() << endl;
if (info.columns() > magick.columns()-10) {
ostringstream os;
os << magick.columns()-10 << "x";
info.resize(os.str());
}
magick.composite(info,
Magick::Geometry(info.columns(), info.rows(), 10, magick.rows()-info.rows()-10),
MagickCore::DissolveCompositeOp);
magick.write("magick-label-composite.jpg");
}
catch (const std::exception& ex)
{
cerr << "failed to magick - " << ex.what() << endl;
ret = 1;
}
return ret;
}