Fredrik Lundh is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

effbot / pil-2009-raclette http://effbot.org/zone/pil-index.htm

Work repository for PIL 1.1.7 and beyond. The "default" branch should be fairly solid, the other branches less so. For production use, see the pil-117 repository.

Clone this repository (size: 1.6 MB): HTTPS / SSH
hg clone https://bitbucket.org/effbot/pil-2009-raclette
hg clone ssh://hg@bitbucket.org/effbot/pil-2009-raclette

pil-2009-raclette / libImaging / Negative.c

/*
 * The Python Imaging Library
 * $Id: Negative.c 2134 2004-10-06 08:55:20Z fredrik $
 *
 * negate image
 *
 * to do:
 *      FIXME: Maybe this should be implemented using ImagingPoint()
 *
 * history:
 *      95-11-27 fl:    Created
 *
 * Copyright (c) Fredrik Lundh 1995.
 * Copyright (c) Secret Labs AB 1997.
 *
 * See the README file for information on usage and redistribution.
 */


#include "Imaging.h"


Imaging
ImagingNegative(Imaging im)
{
    Imaging imOut;
    int x, y;

    if (!im)
        return (Imaging) ImagingError_ModeError();

    imOut = ImagingNew(im->mode, im->xsize, im->ysize);
    if (!imOut)
        return NULL;

    for (y = 0; y < im->ysize; y++)
        for (x = 0; x < im->linesize; x++)
             imOut->image[y][x] = ~im->image[y][x];

    return imOut;
}