
    e#                        d dl mZ ddlmZmZ ddlmZ ddlmZ dZ	d Z
 e
       Zdd	d
dZddd dZd Z ej                  de        ej                   dd        ej"                  dd       y)    )annotations   )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            	     &   t        j                  ddt        t              f      } | j	                  t        t        t        t                                 d}t        D ]  }||z  }	 |ddt        t              z
  z  z  }| j                  |       | S )NLr    r      )r   newlen_Palm8BitColormapValuesputdatalistrange
putpalette)imagepalettedatacolormapValues      5/usr/lib/python3/dist-packages/PIL/PalmImagePlugin.pybuild_prototype_imager*   U   s    IIcAs#:;<=E	MM$uS!89:;<K0 %}$%9c*A&B BCCK	[!L    i @  i   i    )custom-colormapzis-compressedzhas-transparentr	   )nonerlescanlinec           
        | j                   dk(  rd}d}d}n| j                   dk(  r| j                  j                  d      dv r.| j                  d   }| j                  d|z
  d|z  dz
  fd      } nb| j                  j                  d      dv r*| j                  d   }| j                  d|z  dz
  fd      } nd	| j                    d
}t        |      d| _         dt        |      z   }d}n1| j                   dk(  rd}d}d}nd	| j                    d
}t        |      | j                          | j                  d   }| j                  d   }t        |d|z  dz
  z   d|z  z        dz  }	d}
t        d   }d}| j                   dk(  rQd| j                  v rC|t        d   z  }d}| j                  j                   }| j                         j                         }nd}d| j                  v r|	|z  dz   dz   |z   dz  }nd}|j                  t!        |      t!        |      z   t!        |	      z   t!        |      z          |j                  t#        |             |j                  t#        |             |j                  t!        |             |j                  t#        |
             |j                  t#        |             |j                  t!        d             |dkD  r|j                  t!        d             t%        d      D ]  }|j                  t#        |             dk(  rK|j                  t#        d|z           t#        |d|z  dz            z   t#        |d|z  dz            z          m|dk(  ss|j                  t#        d|z           t#        |d|z  dz            z   t#        |d|z  dz            z           t'        j(                  | |dd| j                  z   d||	dffg       t+        |d      r|j-                          y y )NP   r   r   bpp)r         c                    || |z	  z
  S Nr   )xshiftmaxvals      r)   <lambda>z_save.<locals>.<lambda>   s    !u*@U r+   c                    || |z  z
  S r7   r   )r8   r:   s     r)   r;   z_save.<locals>.<lambda>   s    6QZ;P r+   zcannot write mode z as PalmzP;1z1;Ir      r4   r-   r,   i  offset   r5   r   RGBRGBAraw)r   r   flush)modeencoderinfogetpointinfoOSErrorstrloadsizeint_COMPRESSION_TYPES_FLAGSpalettegetdata
getpalettewriteo16br   r$   r   _savehasattrrD   )imfpfilenamerawmoder3   versionmsgcolsrowsrowbytestransparent_indexcompression_typeflagscolormapsizecolormapmodecolormapr?   is                     r)   rV   rV   s   s   	ww#~ 	C>>e$	1 ..'C !CcQUB WW[[9, ''%.CAH>PQB&rwwix8C#, S/	C #277)84cl GGI 771:D771:DDB#IM*rSy9:Q>H)&1E	ww#~+rww6011"zz::<**,277T/B&*\9a?HHT$Z$t*$tH~5UCDHHRWHHR[HHT&\HHR!"#HHR !"HHT!W a
cs 	AHHRUOu$xA'!a%!),-.!a%!),-.
 'xA'!a%!),-.!a%!),-.	  OOBeVbgg%5q7Ha:PQRSr7

 r+   Palmz.palmz
image/palmN)
__future__r    r   r   _binaryr   r   rU   r!   r*   Palm8BitColormapImagerP   rO   rV   register_saveregister_extensionregister_mimer   r+   r)   <module>rp      s    #   "@H J ./  $fQW	X"4TB eV   FE "    )   FL )r+   