Re: gdk_pixbuf_new_from_file_at_size?



> 
> 
> =09Hello everybody,
> 
> for a library I am developing I currently use the function
> gnome_pixmap_new_from_file_at_size, but I doesn't work for me, it just
> load the image with is default size.
> 
> =09I search in gdk_pixbuf library but I haven't found a=20
> gdk_pixbuf_new_from_file_at_size function...=20
> will gdk-pixbuf library have it in a future?

Maybe Federico has an idea here (as to what the future api will hold)
... but even without it, doing a resize is pretty simple.

The function below will scale a pixbuf to a new width/height, and
return a new pixbuf.  You can then render the result to a drawable using
the right function.

static GdkPixbuf *
pixbuf_scale(GdkPixbuf *pb, int wwidth, int wheight)
{
  GdkPixbuf *pb2;
  double scale[6];
  int width = gdk_pixbuf_get_width(pb);
  int height = gdk_pixbuf_get_height(pb);

  if (wwidth==width && wheight==height)
    return pb;

  pb2 =  gdk_pixbuf_new(ART_PIX_RGB, 0, 8, wwidth, wheight);

  /* clear pixbuf dest */
  memset(gdk_pixbuf_get_pixels(pb2), 0, gdk_pixbuf_get_rowstride(pb2)*wheight);
  
  art_affine_scale(scale, (double)wwidth/(double)width, (double)wheight/(double)height);
  
  /* scale screen data */
  art_rgb_pixbuf_affine(gdk_pixbuf_get_pixels(pb2),
                        0, 0, wwidth, wheight,
                        gdk_pixbuf_get_rowstride(pb2),
                        pb->art_pixbuf, scale, ART_FILTER_NEAREST, NULL);

  /* throw away the old one */
  gdk_pixbuf_unref(pb);
  pb = pb2;
  return pb;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]