Logo Search packages:      
Sourcecode: adesklets version File versions

Imlib_Image imlib_create_cropped_image ( int  x,
int  y,
int  width,
int  height 
)

Parameters:
x The top left x coordinate of the rectangle.
y The top left y coordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
Returns:
A valid image, otherwise NULL.
Creates a duplicate of a (x, y, width, height) rectangle in the current image and returns a valid image handle on success, or NULL on failure.

Definition at line 2922 of file imlib2.c.

{
   ImlibImage         *im, *im_old;

   if (!ctx)
      ctx = imlib_context_new();
   CHECK_PARAM_POINTER_RETURN("imlib_create_cropped_image", "image",
                              ctx->image, NULL);
   CAST_IMAGE(im_old, ctx->image);
   if ((!(im_old->data)) && (im_old->loader) && (im_old->loader->load))
      im_old->loader->load(im_old, NULL, 0, 1);
   if (!(im_old->data))
      return NULL;
   im = __imlib_CreateImage(abs(width), abs(height), NULL);
   im->data = malloc(abs(width * height) * sizeof(DATA32));
   if (!(im->data))
     {
        __imlib_FreeImage(im);
        return NULL;
     }
   if (IMAGE_HAS_ALPHA(im_old))
     {
        SET_FLAG(im->flags, F_HAS_ALPHA);
      __imlib_BlendImageToImage(im_old, im, 0, 0, 1, x, y, abs(width),
                          abs(height), 0, 0, width, height, NULL,
                          IMLIB_OP_COPY,
                          ctx->cliprect.x, ctx->cliprect.y,
                          ctx->cliprect.w, ctx->cliprect.h);
     }
   else
     {
      __imlib_BlendImageToImage(im_old, im, 0, 0, 0, x, y, abs(width),
                          abs(height), 0, 0, width, height, NULL,
                          IMLIB_OP_COPY,
                          ctx->cliprect.x, ctx->cliprect.y,
                          ctx->cliprect.w, ctx->cliprect.h);
     }
   return (Imlib_Image) im;
}


Generated by  Doxygen 1.6.0   Back to index