forked from gpolo/pil-py3k
/
Access.c
63 lines (49 loc) · 1.06 KB
/
Access.c
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
59
60
61
62
63
/*
* The Python Imaging Library
* $Id: Access.c 2134 2004-10-06 08:55:20Z fredrik $
*
* imaging access objects
*
* an access object can convert image data on the fly
*
* history:
* 98-12-29 fl Created
*
* Copyright (c) Secret Labs AB 1998.
*
* See the README file for information on usage and redistribution.
*/
#include "Imaging.h"
static void
access_destroy(ImagingAccess access)
{
/* nop */
}
static int
access_getline(ImagingAccess access, char* buffer, int y)
{
memcpy(buffer, access->im->image[y], access->im->linesize);
return 1;
}
ImagingAccess
ImagingAccessNew(Imaging im)
{
/* Create a standard access object */
ImagingAccess access;
access = calloc(1, sizeof(struct ImagingAccessInstance));
if (!access)
return (ImagingAccess) ImagingError_MemoryError();
access->im = im;
access->getline = access_getline;
access->destroy = access_destroy;
return access;
}
void
ImagingAccessDelete(ImagingAccess access)
{
if (!access)
return;
if (access->destroy)
access->destroy(access);
free(access);
}