星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

viewrgb.ps 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. % Copyright (C) 2009 Artifex Software, Inc. 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, modified
  7. % or distributed except as expressly authorized under the terms of that
  8. % license. Refer to licensing information at http://www.artifex.com/
  9. % or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
  10. % San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
  11. % $Id: viewrgb.ps 9517 2009-03-02 19:47:28Z giles $
  12. % viewrgb.ps
  13. % Display a raw RGB file created by -sDEVICE=bitrgb.
  14. % If SCALE is defined, maps input pixels to output pixels with that scale;
  15. % if SCALE is undefined, scales the image to fit the page.
  16. % If BITS is defined, it is the number of bits per sample (1,2,8,12).
  17. % NB: BITS=1 (corresponding to -dGrayValues=16) is not supported.
  18. % if BITS is undefined, its default value is 1.
  19. /viewrgb { % <filename> <width> viewrgb -
  20. 20 dict begin
  21. /w exch def
  22. /fname exch def
  23. /bpc /BITS where { pop BITS } { 1 } ifelse def
  24. /f fname (r) file def
  25. mark fname status pop pop pop /flen exch def cleartomark
  26. /h flen
  27. w [ 0 4 8 0 0 0 0 0 24 ] bpc get
  28. dup 0 eq {
  29. (*** -dBITS=) print bpc =print ( is not supported. ***) = flush
  30. quit
  31. } if
  32. mul 7 add 8 idiv idiv def
  33. QUIET not { (Dimensions: ) print [w h] == flush } if
  34. % Set up scaling.
  35. /SCALE where {
  36. pop
  37. % Map pixels SCALE-for-1. Assume orthogonal transformation.
  38. SCALE 1 0 dtransform add abs div
  39. SCALE 0 1 dtransform add abs div
  40. } {
  41. % Scale the image (uniformly) to fit the page.
  42. clippath pathbbox pop pop translate
  43. pathbbox 3 -1 roll sub h div
  44. 3 1 roll exch sub w div .min dup
  45. } ifelse scale
  46. bpc 1 eq {
  47. [ /Indexed /DeviceRGB 15 <
  48. 000000
  49. 0000FF
  50. 00FF00
  51. 00FFFF
  52. FF0000
  53. FF00FF
  54. FFFF00
  55. FFFFFF
  56. 000000
  57. 0000FF
  58. 00FF00
  59. 00FFFF
  60. FF0000
  61. FF00FF
  62. FFFF00
  63. FFFFFF
  64. >
  65. ] setcolorspace
  66. /BPC 4 def % change to 4 bit indexed
  67. } {
  68. bpc 2 eq {
  69. [ /Indexed /DeviceRGB 255 <
  70. 000000 000055 0000AA 0000FF
  71. 005500 005555 0055AA 0055FF
  72. 00AA00 00AA55 00AAAA 00AAFF
  73. 00FF00 00FF55 00FFAA 00FFFF
  74. 550000 550055 5500AA 5500FF
  75. 555500 555555 5555AA 5555FF
  76. 55AA00 55AA55 55AAAA 55AAFF
  77. 55FF00 55FF55 55FFAA 55FFFF
  78. AA0000 AA0055 AA00AA AA00FF
  79. AA5500 AA5555 AA55AA AA55FF
  80. AAAA00 AAAA55 AAAAAA AAAAFF
  81. AAFF00 AAFF55 AAFFAA AAFFFF
  82. FF0000 FF0055 FF00AA FF00FF
  83. FF5500 FF5555 FF55AA FF55FF
  84. FFAA00 FFAA55 FFAAAA FFAAFF
  85. FFFF00 FFFF55 FFFFAA FFFFFF
  86. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  87. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  88. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  89. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  90. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  91. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  92. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  93. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  94. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  95. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  96. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  97. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  98. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  99. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  100. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  101. 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000
  102. >
  103. ] setcolorspace
  104. /BPC 8 def % change to 4 bit indexed
  105. } {
  106. /DeviceRGB setcolorspace
  107. /BPC bpc def
  108. }
  109. ifelse
  110. }
  111. ifelse
  112. << /ImageType 1
  113. /Width w
  114. /Height h
  115. /BitsPerComponent BPC
  116. /ImageMatrix [1 0 0 -1 0 h]
  117. /DataSource f
  118. /MultipleDataSources false
  119. bpc 4 lt { /Decode [ 0 [ 0 15 255 ] bpc get ] } { /Decode [ 0 1 0 1 0 1 ] } ifelse
  120. >> image
  121. showpage
  122. f closefile
  123. end
  124. } bind def
  125. % If the program was invoked from the command line, run it now.
  126. [ shellarguments {
  127. counttomark 2 eq {
  128. cvi viewrgb
  129. } {
  130. cleartomark
  131. (\nUsage: gs -- viewrgb.ps filename.rgb width\n) print
  132. ( e.g.: gs -- viewrgb.ps my.rgb 2550\n) print flush
  133. ( -dSCALE=### sets specific scaling \(default = 1.0\)) = flush
  134. ( -dBITS=# sets the BitsPerComponent \(1, 2, 8, 12] \(default = 1\)) = flush
  135. } ifelse
  136. } {
  137. pop
  138. } ifelse