Pillow/src/libImaging/Negative.c

43 lines
779 B
C
Raw Normal View History

2010-07-31 06:52:47 +04:00
/*
* The Python Imaging Library
* $Id$
*
* negate image
*
* to do:
* FIXME: Maybe this should be implemented using ImagingPoint()
*
* history:
2020-05-01 15:08:57 +03:00
* 95-11-27 fl: Created
2010-07-31 06:52:47 +04:00
*
* 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
2021-01-03 06:17:51 +03:00
ImagingNegative(Imaging im) {
2010-07-31 06:52:47 +04:00
Imaging imOut;
int x, y;
2020-05-10 12:56:36 +03:00
if (!im) {
2021-01-03 06:17:51 +03:00
return (Imaging)ImagingError_ModeError();
2020-05-10 12:56:36 +03:00
}
2010-07-31 06:52:47 +04:00
imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize);
2020-05-10 12:56:36 +03:00
if (!imOut) {
2020-05-01 15:08:57 +03:00
return NULL;
2020-05-10 12:56:36 +03:00
}
2010-07-31 06:52:47 +04:00
2020-05-10 12:56:36 +03:00
for (y = 0; y < im->ysize; y++) {
for (x = 0; x < im->linesize; x++) {
2020-05-01 15:08:57 +03:00
imOut->image[y][x] = ~im->image[y][x];
2020-05-10 12:56:36 +03:00
}
}
2010-07-31 06:52:47 +04:00
return imOut;
}