Changeset 2668


Ignore:
Timestamp:
Aug 4, 2008, 7:23:51 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • pipi.c: implement pipi_copy().
Location:
libpipi/trunk/pipi
Files:
2 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
  • libpipi/trunk/pipi/pipi.h

    r2667 r2668  
    6767extern pipi_image_t *pipi_load(const char *);
    6868extern pipi_image_t *pipi_new(int, int);
     69extern pipi_image_t *pipi_copy(pipi_image_t *);
    6970extern void pipi_free(pipi_image_t *);
    7071extern void pipi_save(pipi_image_t *, const char *);
Note: See TracChangeset for help on using the changeset viewer.