GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 172.67.177.218  /  Your IP : 216.73.216.243
Web Server : LiteSpeed
System : Linux premium229.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User : akhalid ( 749)
PHP Version : 8.3.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/share/ghostscript/Resource/Init/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/ghostscript/Resource/Init/gs_img.ps
% Copyright (C) 2002-2018 Artifex, Inc.  All rights reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% For more information about licensing, please refer to
% http://www.ghostscript.com/licensing/. For information on
% commercial licensing, go to http://www.artifex.com/licensing/ or
% contact Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
% CA 94945, U.S.A., +1(415)492-9861.

% image, colorimage, and imagemask implementation

%
% The design of the overprint facility in Ghostscript requires that color
% specifications include the color space from which they were expressed,
% even after conversion to the device color model. Directly including this
% information in color specifications is usually not efficient, and is
% difficult to integrate into the existing code structure. The alternative
% approach taken is to extend a state mechanism through the device
% interface, and make the current color space, or more specifically,
% certain information about the current color space, a property of this
% state.
%
% For such a mechanism to work, it is necessary to identify all changes
% to the current color space. This is accomplished in the graphic library
% by funneling all changes to the current color space through the
% gs_setcolorspace procedure. At the PostScript interpreter level, this
% result is achieved by forcing color space changes through the
% setcolorspace operator.
%
% Aside from explicit use of setcolorspace, PostScript provides a few
% implicit methods of changing the current color space. The setgray,
% setrgbcolor, and setcmykcolor operators implicitly set the color space
% while explicitly setting the current color. Similarly, the colorimage
% operator and the traditional form of the image operator (5 operands)
% both temporarily modify the current color space while an image is
% being processed. The current file is concerned with the implementation
% of these two operators. In addition, the traditional form of the
% imagemask operator (5 operands), while it does not affect the current
% color space, is closely related to the image operator and thus is
% implemented in this file as well.
%
% In this implementation, all sampled objects are passed through one of
% the internal operators .image1, .imagemask1, .image2,
% .image3, or .image4, each of which handles a specific ImageType value.
%
% The procedures in this file are responsible for constructing
% image dictionaries from a set of stack entries. This is, in principle,
% a trivial exercise. In practice it appears to be far more complex,
% primarily due to the need to reconstruct the original state in the
% event of an error. This is a particular problem for operators such as
% image, which include data source objects that may, directly or
% indirectly, be procedures. When these procedures are executed, the
% image operator's operands must have been cleared from the operand
% stack. Hence, the operand stack cannot be used to store state
% information. Similarly, the dictionary stack also cannot be used to
% store state information, as the data source procedures may depend on
% a particular dictionary being on the top of this stack.
%
% Adobe's PostScript implementations determine the extent to which the
% interpreter state is restored in the event of an error by the point at
% which the error is detected. Errors in the image/colorimage/imagemask
% operators that are detected before the data source procedures are
% executed restore the state in effect before the image was processed.
% Those that are detected as part of running the data source procedures
% only attempt to restore the state to that in effect at the start of
% the operator that failed (or at the conclusion of the data source
% procedure, if this procedure failed to push a string).
%
% The implementation given here follows the Adobe convention. The
% mechanism used is as follows:
%
%   1. Check that the stack has a sufficient number of operands, and
%      that enough of them have the proper type to allow construction
%      of the image dictionary. Any errors at this point are handled
%      in the conventional manner.
%
%   2. Build the image dictionary, in the process clearing the image/
%      colorimage/imagemask operands from the stack. No errors can
%      occur during this process.
%
%      (Special precautions could be taken during this step to handle
%      a limitcheck or VMError during the building of the image
%      dictionary, but this essentially never occurs in practice and, if
%      it did, is very unlikely to leave a useable state. Hence, we don't
%      bother with this possibility.)
%
%   3. The .image operator is executed in a stopped context. If it
%      returns abnormally, a check is made to see if the uppermost
%      operand on the stack is a color image dictionary. If so, the
%      original stack is created anew using this dictionary. (Because
%      the image operand works via colorimage, some additional special
%      handling is required in this case.)
%

%
% Create a dictionary of operators for specific image and image mask types.
% Each of these will always handle ImageType 1. Additional types are added
% as they are supported in specific interpreter levels or versions.
%
% These dictionaries are in systemdict for historical reasons.
%
.currentglobal //true .setglobal
systemdict begin
/.imagetypes
  5 dict
  dup 1 /.image1 load put
def
/.imagemasktypes
  5 dict
  dup 1 /.imagemask1 load put
def

%
% Some useful local data structures:
%
%   img_csary maps the number of components in an image to the implied
%       color space.
%
%   img_decary is a prototype Decode array; subintervals of this array
%       may be used for fewer than 4 color components.
%
%   img_params_ary is a list of the parameters to be built in the image
%       dictionary for a colorimage invocation. ImageType is given a
%       fixed value; the other parameters are in stack order (IMG_NComps
%       is the number of components).
%
%   img_mask_params_ary is the equivalent of img_params_ary for imagemask
%       invocations. Polarity is a proxy for Decode, and is replaced
%       by the Decode key in the image dictionary.
%
%   img_mask_check_ary is the set of parameters that must be present in
%       an image dictionary generated by an imagemask invocation. This
%       differs from img_mask_params_ary in that Decode replaces Polarity.
%
/img_csary [ //null /DeviceGray //null /DeviceRGB /DeviceCMYK ] def
/img_decary [ 0 1  0 1  0 1  0 1 ] def

/img_params_ary
  [
    /ImageType  /IMG_NComps  /MultipleDataSources  /DataSource
    /ImageMatrix  /BitsPerComponent  /Height  /Width   /Decode
  ]
def
/img_check_ary //img_params_ary def
/img_unbuild_ary
 //img_params_ary 1 1 index length 2 sub getinterval
def

/img_mask_params_ary
  [ /ImageType  /DataSource  /ImageMatrix  /Polarity  /Height  /Width ]
def
/img_mask_check_ary
  [
    /ImageType  /BitsPerComponent
    /DataSource  /ImageMatrix  /Decode  /Height  /Width
  ]
def
/img_mask_unbuild_ary
 //img_mask_check_ary 2 1 index length 2 sub getinterval
def

%
%   <?any?>  <array>   img_check_keys   <?any?>  <bool>
%
% Verify that:
%   that there are at least two entries on the stack, and
%   the second (lower) entry is a dictionary, and
%   that dictionary contains all of the keys in the array
%
% If any one of these conditions does not hold, pop the array and push
% false; otherwise pop the array and push true. This utility is used by
% the colorimage and imagematrix procedures to determine if .image left
% the image dictionary on the stack after an abnormal return.
%
/img_check_keys
  {
    count 2 ge
      {
        1 index type /dicttype eq
          {
            //true exch
              {
                2 index exch known and
                dup not
                  { exit }
                if
              }
            forall
          }
          { pop //false }
        ifelse
      }
      { pop //false }
    ifelse
  }
.bind def

%
% Procedures to convert a set of stack entries to a dictionary. There is
% a procedure associated with each key, though most keys use the same
% procedure. The dictionary to be built is at the top of the dictionary
% stack. Stack handling for the procedures is:
%
%   <?val0?> ... <?val(n - 1)?>  <key>   proc   -
%
% Parameters are handle in inverse-stack order, so inter-parameter
% dependencies that on the stack can generally be used here.
%
/img_params_dict
  mark
    /ImageType { 1 def } .bind

    /IMG_NComps { exch def } .bind      % number of components
    /MultipleDataSources 1 index
    /Width 1 index
    /Height 1 index
    /ImageMatrix 1 index
    /BitsPerComponent 1 index
    /DataSource 1 index

    % Polarity is a proxy for Decode; it never appears in a dictionary
    /Polarity
      {
        pop
          { { 1 0 } }
          { { 0 1 } }
        ifelse
        /Decode exch cvlit def
      }
    .bind

    % the definition of Decode is based on the number of components
    /Decode { //img_decary 0 IMG_NComps 2 mul getinterval def } .bind
  .dicttomark
def

%
%    <oper_0>  ...  <oper_n>  <array>   img_build_dict   <dict>
%
% Build a dictionary. This will always be done in local VM. The array is
% a list of the keys to be associated with operands on the stack, in
% inverse stack order (topmost element first). The caller should verify
% that the dictionary can be built successfully (except for a possible
% VMerror) before calling this routine.
%
/img_build_dict
  {
    % build the dictionary in local VM; all for 2 extra entries
    .currentglobal //false .setglobal
    1 index length 2 add dict
    exch .setglobal
    begin

    % process all keys in the array
      { //img_params_dict 1 index get exec }
    forall

    % if BitsPerComponent is not yet defined, define it to be 1
    currentdict /BitsPerComponent known not
      { /BitsPerComponent 1 def }
    if

    currentdict end
  }
.bind def

%
%   <dict>  <array>   img_unbuild_dict   <oper_0>  ...  <oper_n>
%
% "Unbuild" a dictionary: spread the contents the dictionary back onto the
% stack, in the inverse of the order indicated in the array (inverse is
% used as this order is more convenient for img_build_dict, which is
% expected to be invoked far more frequently).
%
/img_unbuild_dict
  {
    exch begin
    dup length 1 sub -1 0
      { 1 index exch get load exch }
    for
    pop
    end
  }
.bind def

%
% Check the image types that can be used as data sources
% <any> foo <bool>
%
/good_image_types mark
  /filetype { pop //true } .bind
  /stringtype 1 index
  /arraytype //xcheck
  /packedarraytype //xcheck
.dicttomark readonly def

%
%   <width>  <height>  <bits/component>  <matrix>  <dsrc0> ...
%   <multi>  <ncomp>
%   img_build_image_dict
%   <dict>
%
% Build the dictionary corresponding to a colorimage operand stack. This
% routine will check just enough of the stack to verify that the
% dictionary can be built, and will generate the appropriate error if this
% is not the case.
%
% At the first level, errors in this procedure are reported as colorimage
% errors. The error actually reported will usually be determined by the
% pseudo-operator which invokes this routine.
%
/img_build_image_dict
  {
    % Verify that at least 7 operands are available, and that the top two
    % operands have the expected types
    count 7 lt
      { /.colorimage cvx /stackunderflow signalerror }
    if
    2 copy
    type /integertype ne exch
    type /booleantype ne or
      { /.colorimage cvx /typecheck signalerror }
    if

    % verify that the number of components is 1, 3, or 4
    dup 1 lt 1 index 2 eq or 1 index 4 gt or
      { /.colorimage cvx /rangecheck signalerror }
    if

    % Verify that the required number of operands are present if multiple
    % data sources are being used. If this test is successful, convert
    % the data sources to an array (in local VM).
    1 index
      {
        dup dup count 8 sub gt
        {
            % Adobe interpreters appear to test the arguments sequentially
            % starting from the top of the stack and report the 1st error found.
            % To satisfy CET test 12-02.PS we emulate this logic.
            //true exch -1 1
              { 2 add index
                //good_image_types 1 index type .knownget
                  { exec and
                  }
                  { pop pop //false
                  }
                ifelse
              }
            for
              { /stackunderflow
              }
              { /typecheck
              }
            ifelse
            /.colorimage cvx exch signalerror
          }
        if

        % build the DataSource array in local VM
        dup .currentglobal //false .setglobal exch array exch .setglobal

        % stack: <w> <h> <bps> <mtx> <d0> ... <multi> <n> <n'> <array>
        4 1 roll 3 add 2 roll astore 3 1 roll
      }
    if

    % the image dictionary can be built; do so
    % stack: <w> <h> <bps> <mtx> <dsrc|dsrc_array> <multi> <n>
    //img_params_ary //img_build_dict exec
  }
.bind def
currentdict /good_image_types .undef

%
%   <?dict?>
%   img_unbuild_image_dict
%   <width>  <height>  <bits/component>  <matrix>  <dsrc0> ...
%   <multi>  <ncomp>
%
% If the top entry of the stack is a dictionary that has the keys required
% by a colorimage dictionary, unpack that dictionary onto the stack.
% Otherwise just leave things as they are.
%
/img_unbuild_image_dict
  {
    //img_check_ary //img_check_keys exec
      {
        //img_unbuild_ary //img_unbuild_dict exec
        1 index type /booleantype eq
          {
            1 index
              { 3 -1 roll aload length 2 add -2 roll }
            if
          }
        if
      }
    if
  }
.bind def

%
%   <width>  <height>  <polarity>  <matrix>  <dsrc>
%   img_unbuild_imagemask_dict
%   <dict>
%
% Build the dictionary corresponding to an imagemask stack. This routine
% will verify that the appropriate number of operands are on the stack,
% and that polarity is a boolean. This is all that is necessary to build
% the dictionary.
%
/img_build_imagemask_dict
  {
    % check for proper number of operands
    count 5 lt
      { /imagemask .systemvar /stackunderflow signalerror }
    if

    % verify that polarity is a boolean
    2 index type /booleantype ne
      { /imagemask .systemvar /typecheck signalerror }
    if

    % the imagemask dictionary can be built; do so
    //img_mask_params_ary //img_build_dict exec
  }
.bind def

%
%   <?dict?>
%   img_unbuild_imagemask_dict
%   <width>  <height>  <polarity>  <matrix>  <dsrc>
%
% If the top entry of the stack is a dictionary that has the keys rquired
% by an imagemask dictionary, unpack that dictionary onto the stack.
% Otherwise just leave things as they are.
%
/img_unbuild_imagemask_dict
  {
    //img_mask_check_ary //img_check_keys exec
      {
        //img_mask_unbuild_ary //img_unbuild_dict exec
        3 -1 roll
        dup type dup /arraytype eq exch /packedarraytype eq or
        1 index rcheck and
          { 0 get 1 eq }
        if
        3 1 roll
      }
    if
  }
.bind def

%
%   <width>  <height>  <bits/component>  <matrix>  <dsrc_0> ...
%   <multi>  <ncomp>
%   .colorimage
%   -
%
% Convert the image/colorimage operator from their traditional form to
% the dictionary form.
%
% Error handling for these operators is a bit complex, due to the stack
% handling required of operators that potentially invoke procedures.
% This problem is discussed in the comment above. The facts relevant to
% this particular implementation are:
%
%   1. The .image1 operator is executed in a stopped
%      context, so that we can undo the gsave context in the event of
%      an error.
%
%   2. In the event of an error, the stack is examined to see if the
%      dictionary passed to .image1 is still present.
%      If so, this dictionary is "unpacked" onto the stack to re-
%      create the original stack.
%
%   3. The use of pseudo-operators in this case may yield incorrect
%      results for late-detected errors, as the stack depth will be
%      restored (even though the stack is not). This is, however, no
%      worse than the prior (level >= 2) code, so it should cause no
%      new problems.
%
/.colorimage
  {
    % build the image dictionary
    //img_build_image_dict exec

    % execute .image1 in a stopped context
      {
        gsave
        % The CET test file 12-02.ps creates colorimages with a width and
        % height of 0.  Ignore these since that is what the CET expects.
        dup dup /Height get 0 eq exch /Width get 0 eq or
        { pop }	% Ignore colorimage.  Pop dict
          {
            0 .setoverprintmode             % disable overprint mode for images
            //img_csary 1 index /IMG_NComps get get setcolorspace
            .image1
          }
        ifelse
      }
    stopped
    grestore
      {
        //img_unbuild_image_dict exec
        /.colorimage cvx $error /errorname get
        signalerror
      }
    if
  }
.bind def

%
%   <width>  <height>  <bits/component>  <matrix>  <dsrc_0> ...
%   <multi>  <ncomp>
%   colorimage
%   -
%
% Build the colorimage pseudo-operator only if setcolorscreen is visible.
%
systemdict /setcolorscreen .knownget
  {
    type /operatortype eq
      {
        /colorimage
          {
               //.colorimage
             stopped
               { /colorimage .systemvar  $error /errorname get signalerror }
             if
          }
        .bind systemdict begin odef end
      }
    if
  }
if

%
%   width  height  bits_per_component  matrix  data_src   image   -
%
%   <dict>   image   -
%
% Some special handling is required for ImageType 2 (Display PostScript
% pixmap images) so as to set the appropriate color space as the current
% color space.
%
/image
  {
    dup type /dicttype eq .languagelevel 2 ge and
      {
        dup /ImageType get dup 2 eq
          {
            % verify the ImageType 2 is supported
            //.imagetypes exch known
              {
                %
                % Set either DevicePixel or DeviceRGB as the current
                % color space. DevicePixel is used if the image data is
                % to be copied directly, with only a geometric
                % transformation (PixelCopy true). The use of DeviceRGB
                % in the alternate case is not, in general, correct, and
                % reflects a current implementation limitation. Ideally,
                % an intermediate color space should be used only if
                % the source and destination color models vary; otherwise
                % the native color space corresponding to the color model
                % should be used.
                %
                % The mechanism to determine depth for the DevicePixel
                % color space when BitsPerPixel is not available is
                % somewhat of a hack.
                %
                gsave
                0 .setoverprintmode     % disable overprintmode for images
                dup /PixelCopy .knownget dup
                  { pop }
                if
                  {
                      [
                        /DevicePixel
                        currentpagedevice dup /BitsPerPixel .knownget
                          { exch pop }
                          {
                            /GrayValues .knownget not
                              { 2 }     % try a guess
                            if
                            ln 2 ln div round cvi
                          }
                        ifelse
                      ]
                  }
                  { /DeviceRGB }
                ifelse
                setcolorspace
                //.imagetypes 2 get
                stopped
                grestore
                  { /image .systemvar $error /errorname get signalerror }
                if
              }
              { /image .systemvar /rangecheck signalerror
              }
            ifelse
          }
          {
            dup //.imagetypes exch .knownget
              {
                exch pop gsave
                0 .setoverprintmode         % disable overprintmode for images
                stopped
                grestore
                  { /image .systemvar $error /errorname get signalerror }
                if
              }
              {
                /image .systemvar exch type /integertype eq
                  { /rangecheck } { /typecheck }
                ifelse signalerror
              }
            ifelse
          }
        ifelse
      }
      {
        //false 1
          //.colorimage
        stopped
          { /image .systemvar $error /errorname get signalerror }
        if
      }
    ifelse
  }
.bind odef

% An auxiliary function for checking whether an imagemask to be interpolated.
/.is_low_resolution    %  <image dict> .is_low_resolution <bool>
{  % Checking whether image pixel maps to more than 2 device pixels.
   % The threshold 2 is arbitrary.
   1 exch 0 exch
   0 exch 1 exch
   /ImageMatrix get dup
   2 {
     4 1 roll
     idtransform dtransform dup mul exch dup mul add sqrt
   } repeat
   .max
   2 gt % arbitrary
} .bind def

%
%   width  height  polarity  matrix  datasrc   imagemask   -
%
% See the comment preceding the definition of .colorimage for information
% as to the handling of error conditions.
%
/imagemask
  {
    dup type /dicttype eq .languagelevel 2 ge and
      { dup /ImageType get
        //.imagemasktypes exch .knownget
          { 1 index //.is_low_resolution exec
            2 index /ImageType get 1 eq and
            2 index /BitsPerComponent get 1 eq and
            2 index /Interpolate .knownget not { //false } if and
            //filterdict /ImscaleDecode known and
            %%
            %% Don't apply ImScaleDecode to interpolate imagemasks if
            %% the current device is a high level device.
            %%
            /HighLevelDevice /GetDeviceParam .special_op {
              exch pop not
            }{
              //true
            }ifelse
            and
            {
              % Apply interpolated imagemask scaling filter
              exch .currentglobal exch dup .gcheck .setglobal
              dup length dict .copydict
              dup dup /DataSource get
              dup type /stringtype eq {
                1 array astore cvx        % image.* operators read strings repeatesly
              } if
              mark /Width 3 index /Width get /Height 5 index /Height get .dicttomark
              /ImscaleDecode filter /DataSource exch put
              dup dup /Width get 4 mul /Width exch put
              dup dup /Height get 4 mul /Height exch put
              dup dup /ImageMatrix get
              { 4 0 0 4 0 0 } matrix concatmatrix /ImageMatrix exch put
              3 1 roll .setglobal
            } if
            exec
          }
          { % CET 12-08b.ps wants /typecheck
            /imagemask .systemvar /typecheck signalerror
          }
        ifelse
      }
      {
        //img_build_imagemask_dict exec
          { .imagemask1 }
        stopped
          {
            //img_unbuild_imagemask_dict exec
            /imagemask .systemvar $error /errorname get signalerror
          }
        if
      }
    ifelse
  }
.bind odef

% undefine a bunch of local definitions
[
 /.colorimage
 /img_params_dict
 /img_unbuild_dict
 /img_unbuild_image_dict
 /img_unbuild_imagemask_dict
 /img_build_dict
 /img_build_image_dict
 /img_build_imagemask_dict
 /img_check_keys
 /img_mask_check_ary
 /img_params_ary
 /img_mask_unbuild_ary
 /img_mask_params_ary
 /img_csary
 /img_decary
 /img_check_ary
 /img_unbuild_ary
 /.is_low_resolution
]
{currentdict exch .undef} forall

end        % systemdict

.setglobal  % restore VM mode

Youez - 2016 - github.com/yon3zu
LinuXploit