[cairo] resize image surface

chris nuernberger cnuernber at gmail.com
Sat Sep 29 10:58:27 PDT 2012


I don't think that is a very good match really.

I need the *results* of the drawing operation to be packed and contiguous
in memory because as I stated upload to is sensitive to the total data size
and the image data upload functions don't include a stride.

This would in theory render correctly (somewhat) but the original image
surface would still have its original stride.  The subsurfaces are simply a
translation layer sitting above the original surface; I need to data format
of the original surface to change.

I got something working already, it looks like the attached file.  I think
this works in my case because:

1.  I already need all image sizes to be divisible by four (GLES2
limitation).
2.  I am only using pango to render to the surface and then copying the
result off to somewhere else with glTexImage2D.
3.  The damage member is always null so there shouldn't be anything else
relying on the damage.

At least I got it to work rendering to an RGB image surface which has 4
byte pixels for alignment reasons.  It doesn't work (yet) if I switch the
image surface to be alpha-only.  I use the resulting texture in opengl as a
luminance texture so rendering an alpha mask in cairo should be ideal in
terms of memory bandwidth and it fits my use case.


Chris

On Sat, Sep 29, 2012 at 11:37 AM, Kalle Vahlman <kalle.vahlman at gmail.com>wrote:

> 2012/9/29 chris nuernberger <cnuernber at gmail.com>:
> > I was wondering if there was a way to force cairo to treat a surface as
> if
> > it had a smaller width than it was originally allocated with instead when
> > cairo is rendering?  This would solve the problem.
>
> Sounds like you are looking for subsurfaces:
>
>
> http://cairographics.org/manual/cairo-cairo-surface-t.html#cairo-surface-create-for-rectangle
>
> (can't help you with using them though, haven't done anything with them
> myself)
>
> --
> Kalle Vahlman, zuh at iki.fi
> Powered by http://movial.com
> Interesting stuff at http://sandbox.movial.com
>



-- 
A foolish consistency is the hobgoblin of little minds - Emerson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120929/74619946/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_resize.c
Type: text/x-csrc
Size: 1267 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120929/74619946/attachment.c>


More information about the cairo mailing list