Welcome To Support Community

Direct, Draw, and JDraw

Advanced Search
Ask Search:
PhilJonesPhilJones 

How to remove whitespace when saving as image in API.

I'm using the following VB code
        Dim Image As Drawing.Image = renderer.Image
        Image.Save(outputPathTIF, Imaging.ImageFormat.Tiff)
        Image.Save(outputPathGIF, Imaging.ImageFormat.Gif)
        Image.Save(outputPathPNG, Imaging.ImageFormat.Png)

The image is saving with quite a bit of whitespace around it.  How can I remove this?

Thanks,
Phil Jones
James JackJames Jack
Consider using the HeadlessRenderer.  Then you can do like this:

hr.AutoSizeStructure = true;
bitmap = hr.PaintMolecule(mol.MolfileString, StructureType.CTFile, w, h);

"hr"  is the headless renderer, w and h and the required width and height.

Finally - save the bitmap.

This results in a lot less white space for me.