Browse Source

* pipi.c: implement pipi_copy().

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2668 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 years ago
parent
commit
66f9ce5ea4
2 changed files with 22 additions and 0 deletions
  1. +21
    -0
      pipi/pipi.c
  2. +1
    -0
      pipi/pipi.h

+ 21
- 0
pipi/pipi.c View File

@@ -52,3 +52,24 @@ pipi_image_t *pipi_new(int w, int h)
return img;
}

pipi_image_t *pipi_copy(pipi_image_t *src)
{
pipi_image_t *dst = pipi_new(src->w, src->h);

if(src->last_modified != PIPI_PIXELS_UNINITIALISED)
{
pipi_pixels_t *srcp, *dstp;

srcp = &src->p[src->last_modified];
dstp = &dst->p[src->last_modified];

memcpy(dstp, srcp, sizeof(pipi_pixels_t));
dstp->pixels = malloc(dstp->bytes);
memcpy(dstp->pixels, srcp->pixels, dstp->bytes);

dst->last_modified = src->last_modified;
}

return dst;
}


+ 1
- 0
pipi/pipi.h View File

@@ -66,6 +66,7 @@ typedef struct pipi_image pipi_image_t;

extern pipi_image_t *pipi_load(const char *);
extern pipi_image_t *pipi_new(int, int);
extern pipi_image_t *pipi_copy(pipi_image_t *);
extern void pipi_free(pipi_image_t *);
extern void pipi_save(pipi_image_t *, const char *);



Loading…
Cancel
Save