Reputation:
I'm using pycairo to compose images.
Currently I am creating my ImageSurface from a base image and setting a Context from this Surface.
surface = cairo.ImageSurface.create_from_png("base.png")
ctx = cairo.Context (surface)
Then I can for example add text on top:
# draw text
ctx.select_font_face('Sans')
ctx.set_font_size(20)
ctx.move_to(10, 90)
ctx.set_source_rgb(1.00, 0.83, 0.00) # yellow
ctx.show_text('Hello World')
And finally stroking and saving
ctx.stroke()
surface.write_to_png('hello_world.png') # write to file
Apart from text, I also need to load other images and put then on top of my base image at specific locations.
Should I create another surface from a new image and then stack the surfaces, or can I directly load the new image into the context at an specific location as I do with text?
Upvotes: 0
Views: 573
Reputation: 9877
You cannot directly load images into a context. You need more surfaces.
Upvotes: 0