Scaling in exported Image

User 07eebf78ca

29-10-2004 23:19:29

Hi,





It would be nice if there is a "scaleonlytofit" option in the image export. For example, if a benzene ring is exported as an image of size 600x600, the whole picture will be filled with the benzene ring (wide bonds are used and scale > 1). Instead I would like the picture to have lots of blank space with benzene in the center using a scale of 1. To put it in other words, the picture should look as if I took a screenshot of 600x600 MarvinSketch Applet (minus the buttons) loaded with benzene. MarvinSketch does scaling only if the molecule doesnt fit in the applet. I want something similar for image export. Will it be possible? Shouldn't be too difficult to implement considering the fact that MarvinSketch already does that.





Thanks,


Saravana

ChemAxon 7c2d26e5cf

03-11-2004 15:06:29

Without any new option you can solve this scaling problem.


You should calculate the fitting-scaling factor for the molecule. If it is smaller than yours,


you can use your own scaling factor. If not, you should prefer auto scale.


With this trick, you can avoid that the molecule gets off the screen.





Code:



        double scale =26; // required scalling factor


        String format = "jpeg:w600,h600";


        MolImageSize misize = mol.getImageSize(format); // calculate fitting-scaling factor





        // chose the better scalling factor


        if(misize.scale >= scale) {


            format += ",scale"+String.valueOf(scale);


        }


        byte[] data = mol.toBinFormat(format);