git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2668 92316355-f0b4-4df1-b90c-862c8a59935fremotes/tiles
@@ -52,3 +52,24 @@ pipi_image_t *pipi_new(int w, int h) | |||||
return img; | 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; | |||||
} | |||||
@@ -66,6 +66,7 @@ typedef struct pipi_image pipi_image_t; | |||||
extern pipi_image_t *pipi_load(const char *); | extern pipi_image_t *pipi_load(const char *); | ||||
extern pipi_image_t *pipi_new(int, int); | 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_free(pipi_image_t *); | ||||
extern void pipi_save(pipi_image_t *, const char *); | extern void pipi_save(pipi_image_t *, const char *); | ||||