Am Montag, den 17.08.2009, 23:48 +0200 schrieb Greg Landrum:
> Hi Uwe,
> 
> On Mon, Aug 17, 2009 at 11:04 PM, Uwe Hoffmann<u...@family-hoffmann.de> wrote:
> >>
> >      try:
> >        stride = cairo.ImageSurface.format_stride_for_width (
> >          cairo.FORMAT_ARGB32,
> >          image.size[0])
> >        if stride != image.size[0] * 4:
> >          raise Exception ,"invalid stride"
> >      except AttributeError:
> >        stride = image.size[0] * 4
> >
> 
> It probably makes sense for me to go ahead and make this change in
> subversion as well, doesn't it?

in principle yes, but it was a quick hack to get the ball running.
it's possible that some other AttributeErrors will be masked so i think
the following version will be better.

      try:
        cairo.ImageSurface.format_stride_for_width
      except AttributeError:
        stride = image.size[0] * 4
      else:
        stride = cairo.ImageSurface.format_stride_for_width (
          cairo.FORMAT_ARGB32,
          image.size[0])
        if stride != image.size[0] * 4:
          raise Exception ,"invalid stride"

i found some other problem if pycairo is not available:
Chem.Draw.__init__.py should contain the follwing line (MolToImage):
*** 24,29 ****
--- 24,30 ----
        from cairoCanvas import Canvas
        useCAIRO=True
      except:
+       useCAIRO=False
        from rdkit.sping.PIL.pidPIL import PILCanvas as Canvas
        canvas = Canvas(size=size,name='MolToImageFile')
        img = canvas._image

otherwise useCairo can be used without defined.

regards
   Uwe


Reply via email to