Negative.c 720 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * The Python Imaging Library
  3. * $Id$
  4. *
  5. * negate image
  6. *
  7. * to do:
  8. * FIXME: Maybe this should be implemented using ImagingPoint()
  9. *
  10. * history:
  11. * 95-11-27 fl: Created
  12. *
  13. * Copyright (c) Fredrik Lundh 1995.
  14. * Copyright (c) Secret Labs AB 1997.
  15. *
  16. * See the README file for information on usage and redistribution.
  17. */
  18. #include "Imaging.h"
  19. Imaging
  20. ImagingNegative(Imaging im)
  21. {
  22. Imaging imOut;
  23. int x, y;
  24. if (!im)
  25. return (Imaging) ImagingError_ModeError();
  26. imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize);
  27. if (!imOut)
  28. return NULL;
  29. for (y = 0; y < im->ysize; y++)
  30. for (x = 0; x < im->linesize; x++)
  31. imOut->image[y][x] = ~im->image[y][x];
  32. return imOut;
  33. }