[cairo] Blitting surfaces onto each other with coordinate translation
dfnsonfsduifb at gmx.de
Wed Jul 24 21:07:01 UTC 2019
I really have no clue what's going on anymore and really any input could
help me. I've maneuvered myself into a really crappy corner.
What I'm doing: Using pycairo to blit a hardware source with real
measurements. The given external coordinate system has (0, 0) in its
bottom left corner and, for convenience, I calculate everything in
inches in my "hardware" coordinate system, but translate to pixels when
going to my cairo surface.
There's multiple of these surfaces I create, with different offsets to
each other. So one might describe a corner from (0, 0) to (1, 1) and the
next might describe (0.5, 2) to (4, 5) inches. In the end, I want to
compose them all onto each other.
When I create the individual layer surfaces, I translate the Y
matrix = cairo.Matrix()
This allows me to convert from hardware to pixels by just dpi
multiplication and then just draw on the surface.
When I want to create the final surface that all others are merged onto,
I originally had the same setup (i.e., also the final surface would have
an inverted Y axis). But then, for some weird reason, when trying to
blit the sub-surfaces on the destination:
final_cctx.set_source_surface(sub.ctx, sub.offset.x, sub.offset.y)
Then the Y-axis would again be inverted. I'm guessing because it's
inverted again through the projection matrix of the final destination
Now in my testcases I cannot reproduce any of this, there the double
inversion does not happen and, for the life of me, I cannot figure out
what is going on or even how I would start debugging this. I also start
to question if I should also have done the inch/pixel conversion within
the Cairo translation matrix and let everything be handled by Cario
instead of doing a part on my own.
Overall, I'm questioning my sanity.
Can someone help me out on how to debug or move forward? Any help is
All the best,
More information about the cairo