HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/PIL/__pycache__/PyAccess.cpython-38.pyc
U

g�
^�$�@szddlZddlZddlmZe�e�ZdZe�Ze�	e�Gdd�d�Z
Gdd�de
�ZGdd	�d	e
�ZGd
d�de
�Z
Gdd
�d
e
�ZGdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�ZGdd�de
�Zeeeeeeeeeee
e
e
e
eed�Zejdk�rDeed<eed<eed<eed<eed <n(eed<eed<eed<eed<eed <d$d"d#�ZdS)%�N)�FFIz`
struct Pixel_RGBA {
    unsigned char r,g,b,a;
};
struct Pixel_I16 {
    unsigned char l,r;
};
c@s>eZdZd
dd�Zdd�Zdd�Zdd	�ZeZeZd
d�Z	dS)�PyAccessFcCs�t|jj�}||_t�d|d�|_t�d|d�|_t�d|d�|_|jj	\|_
|_|j|_|jj
dkrt|j|_|��dS)Nzunsigned char **�image8zint **�image32�image�P)�dictZimZunsafe_ptrs�readonly�ffi�castrrr�size�xsize�ysize�_im�modeZpalette�_palette�
_post_init)�self�imgr	Zvals�r�./usr/lib/python3/dist-packages/PIL/PyAccess.py�__init__,szPyAccess.__init__cCsdS�Nr)rrrrr>szPyAccess._post_initcCs�|jrtd��|\}}|dkr(|j|}|dkr:|j|}|�||f�\}}|jjdkr~t|tt	f�r~t
|�dkr~|j�|�}|�
|||�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 imagerr)��)r	�
ValueErrorr
r�check_xyrr�
isinstance�list�tuple�lenrZgetcolor�	set_pixel)r�xy�color�x�yrrr�__setitem__As 



��
�zPyAccess.__setitem__cCsJ|\}}|dkr|j|}|dkr,|j|}|�||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
rr�	get_pixel�rr"r$r%rrr�__getitem__^s

zPyAccess.__getitem__cCsF|\}}d|kr|jkr:nnd|kr8|jksBntd��|S)Nrzpixel location out of range)r
rrr(rrrrts2zPyAccess.check_xyN)F)
�__name__�
__module__�__qualname__rrr&r)ZputpixelZgetpixelrrrrrr+s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
_PyAccess32_2z9 PA, LA, stored in first and last bytes of a 32 bit word cOst�d|j�|_dS�Nzstruct Pixel_RGBA **�r
rr�pixels�r�args�kwargsrrrr~sz_PyAccess32_2._post_initcCs|j||}|j|jfSr)r0�r�a�rr$r%�pixelrrrr'�sz_PyAccess32_2.get_pixelcCs2|j||}t|dd�|_t|dd�|_dS)Nr��)r0�minr4r5�rr$r%r#r7rrrr!�sz_PyAccess32_2.set_pixelN�r*r+r,�__doc__rr'r!rrrrr-{sr-c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
_PyAccess32_3zC RGB and friends, stored in the first three bytes of a 32 bit word cOst�d|j�|_dSr.r/r1rrrr�sz_PyAccess32_3._post_initcCs|j||}|j|j|jfSr)r0r4�g�br6rrrr'�sz_PyAccess32_3.get_pixelcCsH|j||}t|dd�|_t|dd�|_t|dd�|_d|_dS)Nrr8r9��r0r:r4r?r@r5r;rrrr!�s
z_PyAccess32_3.set_pixelNr<rrrrr>�sr>c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
_PyAccess32_4z( RGBA etc, all 4 bytes of a 32 bit word cOst�d|j�|_dSr.r/r1rrrr�sz_PyAccess32_4._post_initcCs"|j||}|j|j|j|jfSr)r0r4r?r@r5r6rrrr'�sz_PyAccess32_4.get_pixelcCsR|j||}t|dd�|_t|dd�|_t|dd�|_t|dd�|_dS)Nrr8r9rArrBr;rrrr!�s
z_PyAccess32_4.set_pixelNr<rrrrrC�srCc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
_PyAccess8z' 1, L, P, 8 bit images stored as uint8 cOs|j|_dSr)rr0r1rrrr�sz_PyAccess8._post_initcCs|j||Sr�r0�rr$r%rrrr'�sz_PyAccess8.get_pixelcCsJzt|d�|j||<Wn,tk
rDt|dd�|j||<YnXdS)Nr8r�r:r0�	TypeError�rr$r%r#rrrr!�sz_PyAccess8.set_pixelNr<rrrrrD�srDc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_PyAccessI16_Nz2 I;16 access, native bitendian without conversion cOst�d|j�|_dS)Nzunsigned short **�r
rrr0r1rrrr�sz_PyAccessI16_N._post_initcCs|j||SrrErFrrrr'�sz_PyAccessI16_N.get_pixelcCsJzt|d�|j||<Wn,tk
rDt|dd�|j||<YnXdS)N�rrGrIrrrr!�sz_PyAccessI16_N.set_pixelNr<rrrrrJ�srJc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_PyAccessI16_Lz I;16L access, with conversion cOst�d|j�|_dS�Nzstruct Pixel_I16 **rKr1rrrr�sz_PyAccessI16_L._post_initcCs|j||}|j|jdS�N��r0�lr4r6rrrr'�sz_PyAccessI16_L.get_pixelcCsX|j||}zt|d�}Wn"tk
r>t|dd�}YnX|d@|_|d?|_dS)NrLrr8�)r0r:rHrRr4r;rrrr!�s
z_PyAccessI16_L.set_pixelNr<rrrrrM�srMc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_PyAccessI16_Bz I;16B access, with conversion cOst�d|j�|_dSrNrKr1rrrr�sz_PyAccessI16_B._post_initcCs|j||}|jd|jSrOrQr6rrrr'�sz_PyAccessI16_B.get_pixelcCsX|j||}zt|d�}Wn"tk
r>t|dd�}YnX|d?|_|d@|_dS)NrLrrSr8)r0r:�	ExceptionrRr4r;rrrr!�s
z_PyAccessI16_B.set_pixelNr<rrrrrT�srTc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_PyAccessI32_Nz$ Signed Int32 access, native endian cOs|j|_dSr�rr0r1rrrrsz_PyAccessI32_N._post_initcCs|j||SrrErFrrrr'sz_PyAccessI32_N.get_pixelcCs||j||<dSrrErIrrrr!	sz_PyAccessI32_N.set_pixelNr<rrrrrVsrVc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_PyAccessI32_Swapz. I;32L/B access, with byteswapping conversion cOs|j|_dSrrWr1rrrrsz_PyAccessI32_Swap._post_initcCs\t�d|�}t�d|�}|d|d|d|df\|d<|d<|d<|d<t�d|�dS)Nzint *zunsigned char *rrAr9r)r
�newr)r�iZorig�charsrrr�reverses4z_PyAccessI32_Swap.reversecCs|�|j||�Sr�r\r0rFrrrr'sz_PyAccessI32_Swap.get_pixelcCs|�|�|j||<dSrr]rIrrrr!sz_PyAccessI32_Swap.set_pixelN)r*r+r,r=rr\r'r!rrrrrX
s
rXc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
_PyAccessFz 32 bit float access cOst�d|j�|_dS)Nzfloat **r/r1rrrr#sz_PyAccessF._post_initcCs|j||SrrErFrrrr'&sz_PyAccessF.get_pixelcCs>z||j||<Wn&tk
r8|d|j||<YnXdS)Nr)r0rHrIrrrr!)sz_PyAccessF.set_pixelNr<rrrrr^ sr^)�1�LrZLAZLaZPAZRGBZLABZHSVZYCbCrZRGBAZRGBaZRGBXZCMYK�F�I�littlezI;16zI;16LzI;16BzI;32LzI;32BFcCs.t�|jd�}|s$t�d|j�dS|||�S)NzPyAccess Not Implemented: %s)�mode_map�getr�logger�debug)rr	Zaccess_typerrrrYUs
rY)F)Zlogging�sysZcffirZ	getLoggerr*rfZdefsr
Zcdefrr-r>rCrDrJrMrTrVrXr^rd�	byteorderrYrrrr�<module>s\

P
�