Negative.c 779 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. Imaging imOut;
  22. int x, y;
  23. if (!im) {
  24. return (Imaging)ImagingError_ModeError();
  25. }
  26. imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize);
  27. if (!imOut) {
  28. return NULL;
  29. }
  30. for (y = 0; y < im->ysize; y++) {
  31. for (x = 0; x < im->linesize; x++) {
  32. imOut->image[y][x] = ~im->image[y][x];
  33. }
  34. }
  35. return imOut;
  36. }