Ignore:
Timestamp:
Aug 4, 2008, 7:23:51 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • pipi.c: implement pipi_copy().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/pipi.c

    r2629 r2668  
    5353}
    5454
     55pipi_image_t *pipi_copy(pipi_image_t *src)
     56{
     57    pipi_image_t *dst = pipi_new(src->w, src->h);
     58
     59    if(src->last_modified != PIPI_PIXELS_UNINITIALISED)
     60    {
     61        pipi_pixels_t *srcp, *dstp;
     62
     63        srcp = &src->p[src->last_modified];
     64        dstp = &dst->p[src->last_modified];
     65
     66        memcpy(dstp, srcp, sizeof(pipi_pixels_t));
     67        dstp->pixels = malloc(dstp->bytes);
     68        memcpy(dstp->pixels, srcp->pixels, dstp->bytes);
     69
     70        dst->last_modified = src->last_modified;
     71    }
     72
     73    return dst;
     74}
     75
Note: See TracChangeset for help on using the changeset viewer.