~ubuntu-branches/debian/squeeze/python-imaging/squeeze

« back to all changes in this revision

Viewing changes to libImaging/Fill.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-11-20 19:22:59 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091120192259-n3iy0f17n5akogom
Tags: 1.1.7-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * The Python Imaging Library
3
 
 * $Id: Fill.c 2134 2004-10-06 08:55:20Z fredrik $
 
3
 * $Id$
4
4
 *
5
5
 * fill image with constant pixel value
6
6
 *
20
20
 
21
21
#include "math.h"
22
22
 
23
 
 
24
23
Imaging
25
24
ImagingFill(Imaging im, const void* colour)
26
25
{
27
 
    INT32 c;
28
26
    int x, y;
29
27
 
30
 
    c = 0L;
31
 
    memcpy(&c, colour, im->pixelsize);
32
 
 
33
 
    if (im->image32 && c != 0L) {
34
 
        for (y = 0; y < im->ysize; y++)
35
 
            for (x = 0; x < im->xsize; x++)
36
 
                im->image32[y][x] = c;
 
28
    if (im->type == IMAGING_TYPE_SPECIAL) {
 
29
        /* use generic API */
 
30
        ImagingAccess access = ImagingAccessNew(im);
 
31
        if (access) {
 
32
            for (y = 0; y < im->ysize; y++)
 
33
                for (x = 0; x < im->xsize; x++)
 
34
                    access->put_pixel(im, x, y, colour);
 
35
            ImagingAccessDelete(im, access);
 
36
        } else {
 
37
            /* wipe the image */
 
38
            for (y = 0; y < im->ysize; y++)
 
39
                memset(im->image[y], 0, im->linesize);
 
40
        }
37
41
    } else {
38
 
        unsigned char cc = (unsigned char) *(UINT8*) colour;
39
 
        for (y = 0; y < im->ysize; y++)
40
 
           memset(im->image[y], cc, im->linesize);
 
42
        INT32 c = 0L;
 
43
        memcpy(&c, colour, im->pixelsize);
 
44
        if (im->image32 && c != 0L) {
 
45
            for (y = 0; y < im->ysize; y++)
 
46
                for (x = 0; x < im->xsize; x++)
 
47
                    im->image32[y][x] = c;
 
48
        } else {
 
49
            unsigned char cc = (unsigned char) *(UINT8*) colour;
 
50
            for (y = 0; y < im->ysize; y++)
 
51
                memset(im->image[y], cc, im->linesize);
 
52
        }
41
53
    }
42
54
 
43
55
    return im;