
    h,"                        S SK Jr  S SKJr  SSKJrJr  SSKJr  SSKJ	r
  SrSS jr\" 5       rS	S
SS.rSSS S.rSS jr\R"                  " S\5        \R$                  " SS5        \R&                  " SS5        g)    )annotations)IO   )Image	ImageFile)o8)o16be(   )   r
   r
   )r
      r
   )r
      r
   )r
   f   r
   )r
   3   r
   )r
   r   r
   )r
   r
   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r
   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r   r
   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r   r
   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r
   r
   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r
   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r
   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r
   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )   r   r   )"   r   r   )D   r   r   )U   r   r   )w   r   r   )   r   r   )   r   r   )   r   r   )   r   r   )   r   r   )   r   r   )   r   r   )r   r   r   )r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c            	     *   [         R                  " SS[        [        5      45      n U R	                  [        [        [        [        5      5      5      5        Sn[         H  nX-  nM	     USS[        [        5      -
  -  -  nU R                  U5        U $ )NLr    r      )r   newlen_Palm8BitColormapValuesputdatalistrange
putpalette)imagepalettedatacolormapValues      E/var/www/html/env/lib/python3.13/site-packages/PIL/PalmImagePlugin.pybuild_prototype_imager+   W   s}    IIcAs#:;<=E	MM$uS!89:;<#%K0$ 19c*A&B BCCK	[!L    i @  i   i    )custom-colormapzis-compressedzhas-transparentr
   )nonerlescanlinec                (  ^^ U R                   S:X  a  SnSnSnGO
U R                   S:X  a  U R                  R                  S5      S;   a3  U R                  S   nSU-  S-
  mSU-
  mU R                  UU4S j5      n OgU R                  R                  S5      S;   a-  U R                  S   nSU-  S-
  mU R                  U4S j5      n OS	U R                    S
3n[        U5      eSU l        SU 3nSnO2U R                   S:X  a  SnSnSnOS	U R                    S
3n[        U5      eU R                  5         U R                  S   nU R                  S   n[        USU-  S-
  -   SU-  -  5      S-  n	Sn
[        S   nSnU R                   S:X  a=  U[        S   -  nU R                  R                  5       n[        U5      S-  nSU-  S-   nOSnSU R                  ;   a  X-  S-   S-   U-   S-  nOSnUR                  [!        U5      [!        U5      -   [!        U	5      -   [!        U5      -   5        UR                  [#        U5      5        UR                  [#        U5      5        UR                  [!        U5      5        UR                  [#        U
5      5        UR                  [#        U5      5        UR                  [!        S5      5        U(       ac  UR                  [!        W5      5        [%        U5       H:  nUR                  [#        U5      5        UR                  WSU-  SU-  S-    5        M<     [&        R(                  " X[&        R*                  " SSU R                  -   SX9S45      /5        [-        US5      (       a  UR/                  5         g g )NP   r   r   bpp)r         c                   > TU T-	  -
  $ Nr   )xmaxvalshifts    r*   <lambda>_save.<locals>.<lambda>   s    Fa5j$9r,   c                   > TU T-  -
  $ r8   r   )r9   r:   s    r*   r<   r=      s    Fa&j$9r,   zcannot write mode z as PalmzP;1z1;Ir      r5   r.   r-      r6   offsetraw)r   r   flush)modeencoderinfogetpointinfoOSError_modeloadsizeint_COMPRESSION_TYPES_FLAGSim
getpaletter!   writeo16br   r%   r   _save_TilehasattrrD   )rQ   fpfilenamerawmoder4   versionmsgcolsrowsrowbytestransparent_indexcompression_typeflagscolormapcolorscolormapsizerB   ir:   r;   s                     @@r*   rU   rU   u   s-   	ww#~	C>>e$	1 ..'C3h!^FGE9:BWW[[9, ''%.C3h!^F9:B&rwwix8C#, se*	C #277)84cl GGI 771:D771:DDB#IM*rSy9:Q>H)&1E	ww#~)**55##%X!#6zA~277/B&*\9a?HHT$Z$t*$tH~5UCDHHRWHHR[HHT&\HHR!"#HHR !"HHT!W 
fvAHHRUOHHXa!ea!eai01 
 OO
(8!gQR=STU r7

 r,   Palmz.palmz
image/palmN)returnImage.Image)rQ   ri   rX   z	IO[bytes]rY   zstr | bytesrh   None)
__future__r   typingr    r   r   _binaryr   r	   rT   r"   r+   Palm8BitColormapImagerP   rO   rU   register_saveregister_extensionregister_mimer   r,   r*   <module>rs      s    #    "@H J ./  $fQW	X"4TB Z@   FE "    )   FL )r,   