Hi,

I am trying to render pycairo surfaces on evas's Image object. I can't get
it to work, despite my understanding of evas documentations tells it should.


I found C code snippet that does that (
http://www.google.com/codesearch/p?hl=en#nrTtrP20a6c/evas-0.9.9.037/src/modules/loaders/svg/evas_image_load_svg.c&q=evas%20cairo),
however it can't be copied one-to-one in python.

Following is the code I have, which is a modified version of an example from
python-evas package:

<code>
#!/usr/bin/python
import ecore, ecore.evas
import evas

import cairo

def main():
    ee = ecore.evas.SoftwareX11(w=800, h=480)

    canvas = ee.evas

    bg = canvas.Rectangle(color=(255, 255, 255, 255), size=canvas.size)
    bg.show()

   # create cairo surface
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
    ctx = cairo.Context(surface)
    ctx.rectangle(10,10,80,80)
    ctx.set_source_rgba(1.0,0.7,0.5,1.0)
    ctx.fill()
    print surface.get_stride()  # I get 400
    #data = surface.get_data()

    img2 = canvas.Image()
    img2.image_data_set(surface)
    #img2.image_data_set(data)
    img2.colorspace = evas.EVAS_COLORSPACE_ARGB8888
    img2.fill_set(0,0,100,100)
    img2.image_size_set(100,100)
    print img2.stride           # I get 100 ?
    img2.show()

    ee.show()

    ecore.main_loop_begin()

if __name__ == '__main__':
    main()

</code>

After running this, I end up with a white background surface.

As I understand, evas Image object implements python buffer interface and so
does cairo ImageSurface object. So I thought image_data_set(cairo.Surface)
will do the trick. I also tried using surface.get_data(), (commented out
above), but that didn't work either.

After reading about image formats, I concluded FORMAT_ARGB32 is equivalent
to EVAS_COLORSPACE_ARGB8888. Please correct me if I am wrong.

One thing that troubles me is, stride returned by cairo surface is different
from stride of the evas Image object. I don't know if both libraries have
same notion of stride or not. Could someone tell me what I am doing wrong?

I am using python-evas 0.3 bindings.

Thanks in advance,
---
Jayesh
------------------------------------------------------------------------------
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to