traceimg.ps 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. % Copyright (C) 1994 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: traceimg.ps,v 1.5 2002/06/02 12:03:28 mpsuzuki Exp $
  16. % traceimg.ps
  17. % Trace the data supplied to the 'image' operator.
  18. % This code currently handles only the (Level 2) dictionary form of image,
  19. % with a single data source and 8-bit pixels.
  20. /traceimage % <dict> traceimage -
  21. { currentcolorspace == (setcolorspace\n) print
  22. (<<) print
  23. dup { (\t) print exch ==only ( ) print == } forall
  24. (>>\n) print flush
  25. begin /i_left Width Height mul store /i_dict currentdict store end
  26. { i_left 0 le { exit } if
  27. i_dict /DataSource get exec
  28. dup type /filetype eq
  29. { i_buf 0 i_left 32 .min getinterval readstring pop
  30. } if
  31. dup (%stdout) (w) file exch writehexstring (\n) print flush
  32. i_left exch length sub /i_left exch def
  33. } loop
  34. } bind odef
  35. /image /traceimage load def
  36. /i_left 0 def
  37. /i_dict null def
  38. /i_buf 32 string def