subimages



Hi all!
I found no way to get a subimage out of an image.
So I wrote the function below.
Is it of any interest for integration into gdk?


GdkImage* gdk_image_subimage(GdkImage* origimage, gint x, gint y, gint
w, gint h)
{
  GdkImage *image;
  GdkImagePrivate *priv, *privorig;
  
  g_return_val_if_fail(origimage != NULL, 0);
  
  priv = g_new(GdkImagePrivate, 1);
  privorig = (GdkImagePrivate*)origimage;
  
  image = (GdkImage *)priv;
  priv->xdisplay = privorig->xdisplay;
  priv->image_put = privorig->image_put;
  image->type = origimage->type;
  image->visual = origimage->visual;
  image->width = w;
  image->height = h;
  image->depth = origimage->depth;
  priv->ximage = XSubImage(privorig->ximage, x, y, w, h);
  priv->ximage->bitmap_bit_order = privorig->ximage->bitmap_bit_order;
  priv->ximage->byte_order = privorig->ximage->byte_order;
  image->byte_order = origimage->byte_order;
  image->mem = priv->ximage->data;
  image->bpl = priv->ximage->bytes_per_line;
  image->bpp = origimage->bpp;
  return image;
}



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