星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. % Copyright (C) 1998 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: viewmiff.ps 6300 2005-12-28 19:56:24Z giles $
  16. % viewmiff.ps
  17. % Display a MIFF file. You would think the 'display' command would do this,
  18. % but many versions of 'display' either core-dump or require unacceptably
  19. % large amounts of memory.
  20. % Recognize MIFF keywords.
  21. /miffwords mark
  22. /class { cvn /class exch def }
  23. /colors { cvi /colors exch def }
  24. /columns { cvi /Width exch def }
  25. /compression { cvn /compression exch def }
  26. /depth { cvi /depth exch def }
  27. /packets { cvi /packets exch def }
  28. /rows { cvi /Height exch def }
  29. .dicttomark readonly def
  30. % Recognize MIFF image classes.
  31. /miffclasses mark
  32. /DirectClass {
  33. /DeviceRGB setcolorspace
  34. /BitsPerComponent depth def
  35. /Decode [ 0 1 0 1 0 1 ] def
  36. }
  37. /PseudoClass {
  38. [ /Indexed
  39. % The MIFF documentation lies about the size of pixels
  40. % for this case: the pixel size is determined only by
  41. % the number of colors, and is not affected by the image
  42. % depth. Specifically, if there are 256 or fewer colors
  43. % but the depth (of color map entries) is 16, each pixel
  44. % is still only 1 byte, not 2.
  45. currentdict /colors known {
  46. /DeviceRGB colors 1 sub
  47. /BitsPerComponent colors 256 le { 8 } { 16 } ifelse def
  48. colors 3 mul string depth 8 eq {
  49. f exch readstring pop
  50. } {
  51. % 16-bit color map entries: take only the high-order byte.
  52. 0 1 2 index length 1 sub {
  53. f read pop 2 index 3 1 roll put f read pop pop
  54. } for
  55. } ifelse
  56. } {
  57. /colors 256 def
  58. /DeviceGray 255
  59. 256 string 0 1 255 { 1 index exch dup put } for
  60. } ifelse
  61. ] setcolorspace
  62. /Decode [ 0 1 BitsPerComponent bitshift 1 sub ] def
  63. }
  64. .dicttomark readonly def
  65. % Recognize MIFF compression methods.
  66. /rlstring 768 string def
  67. /rlread {
  68. % packets is not reliable -- disregard it.
  69. dup rlstring 0 3 getinterval readstring {
  70. pop read pop 3 mul 3 3 2 index {
  71. rlstring exch rlstring 0 3 getinterval putinterval
  72. } for
  73. rlstring 0 3 -1 roll 3 add getinterval
  74. } {
  75. pop pop ()
  76. } ifelse
  77. } bind def
  78. /miffcompress mark
  79. /Uncompressed { f }
  80. /RunLengthEncoded { { f rlread } }
  81. /Zip { [ f /FlateDecode filter cvlit /rlread cvx ] cvx }
  82. .dicttomark readonly def
  83. % Read a MIFF file and display the image.
  84. /viewmiff { % <filename> viewmiff -
  85. 50 dict begin
  86. /fname 1 index def
  87. /f exch (r) file def
  88. % Set defaults.
  89. /ImageType 1 def
  90. /class /DirectClass def
  91. /compression /Uncompressed def
  92. /depth 8 def
  93. /packets 16#7fffffff def
  94. % Read and parse the header.
  95. { f token pop
  96. dup (:) eq { pop exit } if
  97. dup type /nametype eq {
  98. .namestring (=) search {
  99. exch pop miffwords exch .knownget { exec } { pop } ifelse
  100. } {
  101. pop % who knows?
  102. } ifelse
  103. } {
  104. pop % probably a comment in braces
  105. } ifelse
  106. } loop
  107. % Read and display the image.
  108. miffclasses class get exec
  109. /DataSource miffcompress compression get exec def
  110. /ImageMatrix [Width 0 0 Height neg 0 Height] def
  111. currentpagedevice /PageSize get
  112. dup 0 get exch 1 get scale
  113. gsave 0.8 setgray 0 0 1 1 rectfill grestore % provide background
  114. currentdict image
  115. showpage
  116. % Clean up.
  117. f closefile
  118. end
  119. } bind def