Hi,
I'm trying to convert a SMILES string to a png picture using openbabel C++
library. Here's a minimal code that says what I want to do.
#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <openbabel/op.h>
#include <openbabel/plugin.h>
#include <iostream>
using namespace std;
using namespace OpenBabel;
int main() {
stringstream inputSmiles("CCC(CC)C");
ofstream pic("minimal_conversion_pic.png");
OBConversion conv(&inputSmiles, &pic);
conv.SetInAndOutFormats("smi", "png");
OBMol mol;
conv.Read(&mol);
OBOp* pOp = OBOp::FindType("gen2D");
pOp->Do(&mol);
conv.Write(&mol);
}
This compiles and runs fine but it generates a png that's only a few bytes
and can't be open. I tried the same code with "png" replaced by "svg" and
it worked. However for various reasons I want to use png instead of svg. I
guess it might be a cairo issue but I'm not sure.
Thanks in advance!
Xianghai Sheng
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss