On Sun, Feb 17, 2013 at 03:29:03PM -0600, Paul Archer wrote:
> I tried adding in a 'cairo_scale', which works. It does seem to slow things
> down a little, but not horribly. That is, it's pretty slow to begin with,
> when the overlay is on, so it doesn't make it much worse.
> My big problem is I can't figure out how to find the right scale. I can
> hard-code numbers, but that will only work with my particular model.
>     cairo_t *cr = cairo_create(priv->pixmap);
>     while (tmp) {
>         image = ENTANGLE_IMAGE(tmp->data);
>         pixbuf = entangle_image_get_pixbuf(image);
> 
>         gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
>         if (tmp == priv->images) {
>             cairo_scale(cr,5,5);
>             cairo_paint(cr);
>         } else {
>             cairo_paint_with_alpha(cr, 0.5); }
> 
>         tmp = tmp->next;
>     }
>     cairo_destroy(cr);

You need to get the first pixbuf on the stack and call gdk_pixbuf_get_width
and gdk_pixbuf_get_height. Then for adjust subsequent images to match.
You're also scaling up the low res image - I'd suggest scaling down
the high res images instead.

So perhaps something like this:

     cairo_t *cr = cairo_create(priv->pixmap);
     int basex, basey;
     while (tmp) {
         image = ENTANGLE_IMAGE(tmp->data);
         pixbuf = entangle_image_get_pixbuf(image);
 
         gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
         if (tmp == priv->images) {
             basex = gdk_pixbuf_image_get_width(pixbuf);
             basey = gdk_pixbuf_image_get_height(pixbuf);
             cairo_paint(cr);
         } else {
             int thisx, thisy;
             double scalex, scaley;
             thisx = gdk_pixbuf_image_get_width(pixbuf);
             thisy = gdk_pixbuf_image_get_height(pixbuf);
             scalex = (double)basex / (double)thisx;
             scaley = (double)basey / (double)thisy;
             cairo_scale(cr, scalex, scaley);
             cairo_paint_with_alpha(cr, 0.5);
         }
 
         tmp = tmp->next;
     }
     cairo_destroy(cr);

This is untested, so I may well have screwed up the math there,
but that's the general approach that ought to work


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

_______________________________________________
Entangle-devel mailing list
Entangle-devel@gna.org
https://mail.gna.org/listinfo/entangle-devel

Reply via email to