pil-2009-raclette / libImaging / Copy.c

/* 
 * The Python Imaging Library
 * $Id$
 *
 * copy image
 *
 * history:
 * 95-11-26 fl   Moved from Imaging.c
 * 97-05-12 fl   Added ImagingCopy2
 * 97-08-28 fl   Allow imOut == NULL in ImagingCopy2
 *
 * Copyright (c) Fredrik Lundh 1995-97.
 * Copyright (c) Secret Labs AB 1997.
 *
 * See the README file for details on usage and redistribution.
 */


#include "Imaging.h"


static Imaging
_copy(Imaging imOut, Imaging imIn)
{
    ImagingSectionCookie cookie;
    int y;

    if (!imIn)
        return (Imaging) ImagingError_ValueError(NULL);

    imOut = ImagingNew2(imIn->mode, imOut, imIn);
    if (!imOut)
        return NULL;

    ImagingCopyInfo(imOut, imIn);

    ImagingSectionEnter(&cookie);
    if (imIn->block != NULL && imOut->block != NULL)
        memcpy(imOut->block, imIn->block, imIn->ysize * imIn->linesize);
    else
        for (y = 0; y < imIn->ysize; y++)
            memcpy(imOut->image[y], imIn->image[y], imIn->linesize);
    ImagingSectionLeave(&cookie);

    return imOut;
}

Imaging
ImagingCopy(Imaging imIn)
{
    return _copy(NULL, imIn);
}

Imaging
ImagingCopy2(Imaging imOut, Imaging imIn)
{
    return _copy(imOut, imIn);
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.