Ejemplo n.º 1
0
        private byte[] RenderHighlightedObject(IndigoObject mol, IndigoObject query)
        {
            query.aromatize();
            IndigoObject matcher = indigo.substructureMatcher(mol);

            foreach (IndigoObject match in matcher.iterateMatches(query))
            {
                foreach (IndigoObject queryAtom in query.iterateAtoms())
                {
                    IndigoObject atom = match.mapAtom(queryAtom);
                    atom.highlight();

                    foreach (IndigoObject nei in atom.iterateNeighbors())
                    {
                        if (!nei.isPseudoatom() && !nei.isRSite() && nei.atomicNumber() == 1)
                        {
                            nei.highlight();
                            nei.bond().highlight();
                        }
                    }
                }

                foreach (IndigoObject bond in query.iterateBonds())
                {
                    match.mapBond(bond).highlight();
                }
            }

            indigo.setOption("render-coloring", false);
            mol.dearomatize();
            mol.layout();
            return(renderer.renderToBuffer(mol));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a depiction of the chemical structure as a bitmap.
        /// </summary>
        /// <param name="width">The desired width in pixels.</param>
        /// <param name="height">The desired height in pixels.</param>
        /// <returns>The bitmap depicting the chemical structure.</returns>
        public Bitmap ToBitmap(int width, int height)
        {
            Bitmap bitmap = null;

            try
            {
                using (Indigo indigo = new Indigo())
                {
                    IndigoRenderer indigoRenderer = new IndigoRenderer(indigo);
                    indigo.setOption("render-coloring", true);
                    indigo.setOption("render-image-size", width, height);
                    indigo.setOption("render-label-mode", "hetero");
                    indigo.setOption("render-margins", 10, 10);
                    indigo.setOption("render-output-format", "png");
                    indigo.setOption("render-relative-thickness", 1.6f);
                    IndigoObject structure = CreateIndigoStructure(indigo);
                    structure.dearomatize();
                    structure.layout();
                    bitmap = indigoRenderer.renderToBitmap(structure);
                    structure.Dispose();
                }
            }
            catch
            {
                bitmap = Properties.Resources.Error;
            }

            return(bitmap);
        }