[cairo] Image rendering help?

Ian Britten britten at caris.com
Mon Sep 29 09:25:16 PDT 2008

Hi all,
I was wondering if someone knowledgeable could take a bit of a
look at the attached (cairomm) test I'm playing with?

I'm still struggling with getting transformations set up right
for rendering images (Especially within our real code), and have
broken it down to a basic sample for discussion purposes.

All I'm trying to do it draw the image at full size on my
surface, and am trying it two different ways - Via an
ImageSurface and via a SurfacePattern (Controlled by setting
the appropriate #define at the top of the file).  The first one
works, but the second one doesn't.  I'm still not sure which
approach to eventually use, and would like to have equivalent
working cases to help evaluate with.

Most of the code just makes the PDF surface, and sets up the
initial transformations the way we have them (Cartesian).  The
only critical code is the bits in the #ifdefs ...

If you're still reading this ;)  , I've got a couple of specific

For the VIA_SURFACE case:
- Why are the translate() calls needed?  Can't I simply set the
   scale, and draw the image at the desired position?  Isn't the
   scale linear over the entire surface, or have I misunderstood
- Is there some way to do this without resorting to device units
   (ie: The 0,0 in the set_source() call)?  In our framework, I'm
   working in User Units, and would really like to draw the image
   at (1000,1000) - The Cartesian lower-left position, in this

For the VIA_PATTERN case:
- (sigh) It doesn't seem to work, even though it seems to be the
   same as my SURFACE case (to me, at least).  Can anyone point
   out what's wrong?
- Ditto that I'd like to draw the image at (1000,1000)
- How does anyone debug this stuff?  When you get 'no output',
   how do you figure out where it went?  Flail?  :(

[Bonus points if the solutions work when the 'angleRad' variable
is non-zero, to rotate the surface about its centre :) ]

Anyways, my sincere thanks for any help, and my apologies for
cluttering up the list with trivialities...

PS - I consciously did *not* attach the image, to keep the size
smaller.  Grab any PNG, and update the imageName accordingly.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 4692 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080929/04472d0d/attachment.cpp 

More information about the cairo mailing list