
    }f&                        U d dl mZ d dlZd dlZddlmZ ded<   	 d dlmZ dZ	 e            Z
e
                    e	           n*# e$ r"Zdd	lmZ  ej        e          xZZ
Y dZ[ndZ[ww xY w ej        e          Z G d
 d          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zi d ed!ed"ed#ed$ed%ed&ed'ed(ed)ed*ed+ed,ed-ed.ed/ed0eZej         d1k    reed2<   eed3<   eed4<   eed5<   eed6<   need2<   eed3<   eed4<   eed5<   eed6<   d9d8ZdS ):    )annotationsN   )	deprecatetypeFFI)r   z|
    struct Pixel_RGBA {
        unsigned char r,g,b,a;
    };
    struct Pixel_I16 {
        unsigned char l,r;
    };
    )DeferredErrorc                  6    e Zd ZddZd Zd Zd ZeZeZd Z	dS )	PyAccessFc                   t          dd           t          |j        j                  }|| _        t
                              d|d                   | _        t
                              d|d                   | _        t
                              d|d                   | _	        |j        j
        \  | _        | _        || _        |j        | _        | j        j        dv r|j        | _        |                                  d S )	Nr
      zunsigned char **image8zint **image32imagePPA)r   dictimunsafe_ptrsreadonlyfficastr   r   r   sizexsizeysize_img_immodepalette_palette
_post_init)selfimgr   valss       E/var/www/rtfcompare/venv/lib/python3.11/site-packages/PIL/PyAccess.py__init__zPyAccess.__init__5   s    *b!!!CF&'' hh14>BBxx$y/::XX0$w-@@
!$
DJ	 68=K''KDM
 	    c                    d S N )r"   s    r%   r!   zPyAccess._post_initI   s    r'   c                *   | j         rd}t          |          |\  }}|dk     r
| j        |z   }|dk     r
| j        |z   }|                     ||f          \  }}| j        j        dv rt          |t          t          f          r|t          |          dv rk| j        j        dk    r't          |          dk    r|d         nd}|d	d         }| j                            || j                  }| j        j        dk    r||f}|                     |||          S )
a0  
        Modifies the pixel at x,y. The color is given as a single
        numerical value for single band images, and a tuple for
        multi-band images

        :param xy: The pixel coordinate, given as (x, y). See
           :ref:`coordinate-system`.
        :param color: The pixel value.
        z%Attempt to putpixel a read only imager   r   )      r   r-   r,      N)r   
ValueErrorr   r   check_xyr   r   
isinstancelisttuplelenr    getcolorr   	set_pixel)r"   xycolormsgxyalphas          r%   __setitem__zPyAccess.__setitem__L   s!    = 	"9CS//!Aq55
QAq55
QA1v&&A HM[((54-00 )E

f$$ x}$$$'JJ!OOabqb	M**5$)<<Ex}$$~~aE***r'   c                    |\  }}|dk     r
| j         |z   }|dk     r
| j        |z   }|                     ||f          \  }}|                     ||          S )aq  
        Returns the pixel at x,y. The pixel is returned as a single
        value for single band images or a tuple for multiple band
        images

        :param xy: The pixel coordinate, given as (x, y). See
          :ref:`coordinate-system`.
        :returns: a pixel value for single band images, a tuple of
          pixel values for multiband images.
        r   )r   r   r0   	get_pixel)r"   r7   r:   r;   s       r%   __getitem__zPyAccess.__getitem__o   sb     Aq55
QAq55
QA1v&&A~~a###r'   c                    |\  }}d|cxk    r| j         k     rn nd|cxk    r| j        k     sn d}t          |          |S )Nr   zpixel location out of range)r   r   r/   )r"   r7   r:   r;   r9   s        r%   r0   zPyAccess.check_xy   se    AQ#########Q(;(;(;(;(;(;(;(;/CS//!	r'   NF)
__name__
__module____qualname__r&   r!   r=   r@   putpixelgetpixelr0   r*   r'   r%   r
   r
   4   sq           (  !+ !+ !+F$ $ $& HH    r'   r
   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccess32_2z7PA, LA, stored in first and last bytes of a 32 bit wordc                P    t                               d| j                  | _        d S Nzstruct Pixel_RGBA **r   r   r   pixelsr"   argskwargss      r%   r!   z_PyAccess32_2._post_init       hh5t|DDr'   c                D    | j         |         |         }|j        |j        fS r)   )rM   rar"   r:   r;   pixels       r%   r?   z_PyAccess32_2.get_pixel   s!    Aq!wr'   c                    | j         |         |         }t          |d         d          |_        t          |d         d          |_        d S )Nr   r.   r   )rM   minrS   rT   r"   r:   r;   r8   rV   s        r%   r6   z_PyAccess32_2.set_pixel   s@    Aq!eAh$$eAh$$r'   NrC   rD   rE   __doc__r!   r?   r6   r*   r'   r%   rI   rI      sJ        AAE E E     % % % % %r'   rI   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccess32_3zARGB and friends, stored in the first three bytes of a 32 bit wordc                P    t                               d| j                  | _        d S rK   rL   rN   s      r%   r!   z_PyAccess32_3._post_init   rQ   r'   c                P    | j         |         |         }|j        |j        |j        fS r)   )rM   rS   gbrU   s       r%   r?   z_PyAccess32_3.get_pixel   s%    Aq!w((r'   c                    | j         |         |         }t          |d         d          |_        t          |d         d          |_        t          |d         d          |_        d|_        d S )Nr   r.   r      rM   rX   rS   r`   ra   rT   rY   s        r%   r6   z_PyAccess32_3.set_pixel   s\    Aq!eAh$$eAh$$eAh$$r'   NrZ   r*   r'   r%   r]   r]      sJ        KKE E E) ) )    r'   r]   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccess32_4z&RGBA etc, all 4 bytes of a 32 bit wordc                P    t                               d| j                  | _        d S rK   rL   rN   s      r%   r!   z_PyAccess32_4._post_init   rQ   r'   c                \    | j         |         |         }|j        |j        |j        |j        fS r)   )rM   rS   r`   ra   rT   rU   s       r%   r?   z_PyAccess32_4.get_pixel   s)    Aq!w%'11r'   c                   | j         |         |         }t          |d         d          |_        t          |d         d          |_        t          |d         d          |_        t          |d         d          |_        d S )Nr   r.   r   rc   r,   rd   rY   s        r%   r6   z_PyAccess32_4.set_pixel   sj    Aq!eAh$$eAh$$eAh$$eAh$$r'   NrZ   r*   r'   r%   rf   rf      sJ        00E E E2 2 2% % % % %r'   rf   c                  $    e Zd ZdZd Zd Zd ZdS )
_PyAccess8z%1, L, P, 8 bit images stored as uint8c                    | j         | _        d S r)   )r   rM   rN   s      r%   r!   z_PyAccess8._post_init   s    kr'   c                (    | j         |         |         S r)   rM   r"   r:   r;   s      r%   r?   z_PyAccess8.get_pixel       {1~a  r'   c                    	 t          |d          | j        |         |<   d S # t          $ r( t          |d         d          | j        |         |<   Y d S w xY w)Nr.   r   rX   rM   	TypeErrorr"   r:   r;   r8   s       r%   r6   z_PyAccess8.set_pixel   sg    	3 #E3DKN1 	3 	3 	3 #E!Hc 2 2DKN1	3   " .AANrZ   r*   r'   r%   rk   rk      sG        //" " "! ! !3 3 3 3 3r'   rk   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccessI16_Nz0I;16 access, native bitendian without conversionc                P    t                               d| j                  | _        d S )Nzunsigned short **r   r   r   rM   rN   s      r%   r!   z_PyAccessI16_N._post_init   s    hh2DJ??r'   c                (    | j         |         |         S r)   rn   ro   s      r%   r?   z_PyAccessI16_N.get_pixel   rp   r'   c                    	 t          |d          | j        |         |<   d S # t          $ r( t          |d         d          | j        |         |<   Y d S w xY w)N  r   rr   rt   s       r%   r6   z_PyAccessI16_N.set_pixel   si    	5 #E5 1 1DKN1 	5 	5 	5 #E!He 4 4DKN1	5ru   NrZ   r*   r'   r%   rw   rw      sJ        ::@ @ @! ! !5 5 5 5 5r'   rw   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccessI16_LzI;16L access, with conversionc                P    t                               d| j                  | _        d S Nzstruct Pixel_I16 **ry   rN   s      r%   r!   z_PyAccessI16_L._post_init       hh4djAAr'   c                L    | j         |         |         }|j        |j        dz  z   S N   rM   lrS   rU   s       r%   r?   z_PyAccessI16_L.get_pixel   s%    Aq!w3&&r'   c                    | j         |         |         }	 t          |d          }n&# t          $ r t          |d         d          }Y nw xY w|dz  |_        |dz	  |_        d S )Nr|   r   r.      )rM   rX   rs   r   rS   rY   s        r%   r6   z_PyAccessI16_L.set_pixel   sv    Aq!	)u%%EE 	) 	) 	)a%((EEE	) $,1*   &  A	A	NrZ   r*   r'   r%   r~   r~      sJ        ''B B B' ' '    r'   r~   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccessI16_BzI;16B access, with conversionc                P    t                               d| j                  | _        d S r   ry   rN   s      r%   r!   z_PyAccessI16_B._post_init   r   r'   c                L    | j         |         |         }|j        dz  |j        z   S r   r   rU   s       r%   r?   z_PyAccessI16_B.get_pixel  s%    Aq!w}uw&&r'   c                    | j         |         |         }	 t          |d          }n&# t          $ r t          |d         d          }Y nw xY w|dz	  |_        |dz  |_        d S )Nr|   r   r   r.   )rM   rX   	Exceptionr   rS   rY   s        r%   r6   z_PyAccessI16_B.set_pixel  sv    Aq!	)u%%EE 	) 	) 	)a%((EEE	) 1*$,r   NrZ   r*   r'   r%   r   r      sJ        ''B B B' ' '    r'   r   c                  $    e Zd ZdZd Zd Zd ZdS )_PyAccessI32_Nz"Signed Int32 access, native endianc                    | j         | _        d S r)   r   rM   rN   s      r%   r!   z_PyAccessI32_N._post_init      lr'   c                (    | j         |         |         S r)   rn   ro   s      r%   r?   z_PyAccessI32_N.get_pixel  rp   r'   c                &    || j         |         |<   d S r)   rn   rt   s       r%   r6   z_PyAccessI32_N.set_pixel  s    !Aqr'   NrZ   r*   r'   r%   r   r     sG        ,,# # #! ! !" " " " "r'   r   c                  *    e Zd ZdZd Zd Zd Zd ZdS )_PyAccessI32_Swapz,I;32L/B access, with byteswapping conversionc                    | j         | _        d S r)   r   rN   s      r%   r!   z_PyAccessI32_Swap._post_init"  r   r'   c                   t                               d|          }t                               d|          }|d         |d         |d         |d         f\  |d<   |d<   |d<   |d<   t                               d|          d         S )Nzint *zunsigned char *r,   rc   r   r   )r   newr   )r"   iorigcharss       r%   reversez_PyAccessI32_Swap.reverse%  sz    www""*D1116q58U1XuUVx1W.a%(E!HeAhxx''**r'   c                N    |                      | j        |         |                   S r)   r   rM   ro   s      r%   r?   z_PyAccessI32_Swap.get_pixel+  s    ||DKN1-...r'   c                L    |                      |          | j        |         |<   d S r)   r   rt   s       r%   r6   z_PyAccessI32_Swap.set_pixel.  s$     LL//Aqr'   N)rC   rD   rE   r[   r!   r   r?   r6   r*   r'   r%   r   r     sV        66# # #+ + +/ / /0 0 0 0 0r'   r   c                  $    e Zd ZdZd Zd Zd ZdS )
_PyAccessFz32 bit float accessc                P    t                               d| j                  | _        d S )Nzfloat **rL   rN   s      r%   r!   z_PyAccessF._post_init5  s    hhz4<88r'   c                (    | j         |         |         S r)   rn   ro   s      r%   r?   z_PyAccessF.get_pixel8  rp   r'   c                v    	 || j         |         |<   d S # t          $ r |d         | j         |         |<   Y d S w xY w)Nr   )rM   rs   rt   s       r%   r6   z_PyAccessF.set_pixel;  sU    	) %DKN1 	) 	) 	) %aDKN1	)s     88NrZ   r*   r'   r%   r   r   2  sG        9 9 9! ! !) ) ) ) )r'   r   1Lr   zI;16NLALar   RGBLABHSVYCbCrRGBARGBaRGBXCMYKFIlittlezI;16zI;16LzI;16BzI;32LzI;32BFc                    t                               | j        d           }|s"t                              d| j                   d S  || |          S )NzPyAccess Not Implemented: %s)mode_mapgetr   loggerdebug)r#   r   access_types      r%   r   r   h  sM    ,,sx..K 3SX>>>t;sH%%%r'   rB   )!
__future__r   loggingsys
_deprecater   __annotations__cffir   defsr   cdefImportErrorex_utilr   r   	getLoggerrC   r   r
   rI   r]   rf   rk   rw   r~   r   r   r   r   r   	byteorderr*   r'   r%   <module>r      s%  * # " " " " " "  



 ! ! ! ! ! ! 				&D #%%CHHTNNNN & & & %$$$$$!!"%%%C######& 
	8	$	$V V V V V V V Vr% % % % %H % % %"    H   &% % % % %H % % %&3 3 3 3 3 3 3 3$5 5 5 5 5X 5 5 5$    X   *    X   *
" 
" 
" 
" 
"X 
" 
" 
"0 0 0 0 0 0 0 0&) ) ) ) ) ) ) )$  ^	
 	- 	- 	- 
= 
= 
= ] M M M M  !" #( =H%HV&HW&HW&HW)HW%HV&HW&HW)HW&HW& & & & & &s   'A A+	A&&A+