File: Copy.c

package info (click to toggle)
python-imaging 1.1.7-4%2Bdeb7u2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,420 kB
  • sloc: ansic: 19,470; python: 11,012; makefile: 111
file content (58 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 
 * 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);
}