Display a structure as an image in the browser

User 478d103dc9

01-05-2013 22:15:15

Hi,


I used JChem Manager to create a structure table. Then through JChem
Manager I imported .SDF file into the table.


Now I want to display a structure as
an
image in the browser for a particulr cd_id.


Any .NET
example would be much appreciated.


Thanks

ChemAxon bd13b5bd77

03-05-2013 09:30:33

Hi,


if you install JChem .NET API you will be finding an Examples folder there under e.g.:


C:\Program Files\ChemAxon\ChemAxon .NET versions\Examples\ASPNETExamples\Sample


here there is a document how to


C:\Program Files\ChemAxon\ChemAxon .NET versions\Examples\ASPNETExamples run the web demo solution.


 


Viktor

ChemAxon bd13b5bd77

03-05-2013 09:32:02

Here are some files from that folder how to render molecule on the web:


Code snippet:


            var molecule =  new JChemMolecule(new MoleculeData(moleculeString, format));
   StructureDrawingInfo drawingInfo = new StructureDrawingInfo();
            drawingInfo.Size = new Size(width, height);
            molecule.Renderer.Settings = new JChemMoleculeRenderingSettings(drawingInfo);
            return molecule.Renderer.RenderToImage(ImageFormat.Bmp);


These cs files contains the most commonly used ChemAxon.NET molecule services.


 

User 478d103dc9

03-05-2013 12:46:16










hamoriviktor wrote:

Here are some files from that folder how to render molecule on the web:


Code snippet:


            var molecule =  new JChemMolecule(new MoleculeData(moleculeString, format));
   StructureDrawingInfo drawingInfo = new StructureDrawingInfo();
            drawingInfo.Size = new Size(width, height);
            molecule.Renderer.Settings = new JChemMoleculeRenderingSettings(drawingInfo);
            return molecule.Renderer.RenderToImage(ImageFormat.Bmp);


These cs files contains the most commonly used ChemAxon.NET molecule services.


 



The MoleculeImageHandler.ashx.cs is the one that I was looking for.


Thank you

User 478d103dc9

03-05-2013 18:42:49










hamoriviktor wrote:

Here are some files from that folder how to render molecule on the web:


Code snippet:


            var molecule =  new JChemMolecule(new MoleculeData(moleculeString, format));
   StructureDrawingInfo drawingInfo = new StructureDrawingInfo();
            drawingInfo.Size = new Size(width, height);
            molecule.Renderer.Settings = new JChemMoleculeRenderingSettings(drawingInfo);
            return molecule.Renderer.RenderToImage(ImageFormat.Bmp);


These cs files contains the most commonly used ChemAxon.NET molecule services.


 



 


Is there is a way
upon drawing an image to change its background color?  It currently
renders in black.


Thanks

ChemAxon bd13b5bd77

04-05-2013 15:35:53

I think you might have problems with the transparency property ...


Have you checked the .NET API as  I suggested there you will get smaller demo codes running on local host (document also exists how to set it up) and you will see that you do not get black moelcules.


 

User 478d103dc9

05-05-2013 16:31:12










hamoriviktor wrote:

I think you might have problems with the transparency property ...


Have you checked the .NET API as  I suggested there you will get smaller demo codes running on local host (document also exists how to set it up) and you will see that you do not get black moelcules.


 



 


It was coming out black until I set the transparency:


bmp.MakeTransparent(Color.Magenta) '--Magenta in bitmap will be transparent