B .^$@szddlZddlZddlmZeeZdZeZe eGdddZ Gddde Z Gdd d e Z Gd d d e Z Gd d d e ZGddde ZGddde ZGddde ZGddde ZGddde ZGddde Zeeee e e e e e e e e e e eedZejdkrDeed<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 ddZddZddZdd ZeZeZd d Z d S)PyAccessFcCst|jj}||_td|d|_td|d|_td|d|_|jj \|_ |_ |j|_ |j j dkrt|j|_|dS)Nzunsigned char **image8zint **image32imageP)dictZimZ unsafe_ptrsreadonlyfficastrrrsizexsizeysize_immodeZpalette_palette _post_init)selfimgr valsr0/tmp/pip-install-mwhup7aw/Pillow/PIL/PyAccess.py__init__,s  zPyAccess.__init__cCsdS)Nr)rrrrr>szPyAccess._post_initcCs|jrtd|\}}|dkr(|j|}|dkr:|j|}|||f\}}|jjdkr~t|tt fr~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 rcheck_xyrr isinstancelisttuplelenrZgetcolor set_pixel)rxycolorxyrrr __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 rr)rr"r$r%rrrrts2zPyAccess.check_xyN)F) __name__ __module__ __qualname__rrr&r(ZputpixelZgetpixelrrrrrr+s rc@s(eZdZdZddZddZddZdS) _PyAccess32_2z9 PA, LA, stored in first and last bytes of a 32 bit word cOstd|j|_dS)Nzstruct Pixel_RGBA **)r r rpixels)rargskwargsrrrr~sz_PyAccess32_2._post_initcCs|j||}|j|jfS)N)r-ra)rr$r%pixelrrrr'sz_PyAccess32_2.get_pixelcCs2|j||}t|dd|_t|dd|_dS)Nr)r-minr0r1)rr$r%r#r2rrrr!sz_PyAccess32_2.set_pixelN)r)r*r+__doc__rr'r!rrrrr,{sr,c@s(eZdZdZddZddZddZdS) _PyAccess32_3zC RGB and friends, stored in the first three bytes of a 32 bit word cOstd|j|_dS)Nzstruct Pixel_RGBA **)r r rr-)rr.r/rrrrsz_PyAccess32_3._post_initcCs|j||}|j|j|jfS)N)r-r0gb)rr$r%r2rrrr'sz_PyAccess32_3.get_pixelcCsH|j||}t|dd|_t|dd|_t|dd|_d|_dS)Nrr3r4)r-r5r0r8r9r1)rr$r%r#r2rrrr!s z_PyAccess32_3.set_pixelN)r)r*r+r6rr'r!rrrrr7sr7c@s(eZdZdZddZddZddZdS) _PyAccess32_4z( RGBA etc, all 4 bytes of a 32 bit word cOstd|j|_dS)Nzstruct Pixel_RGBA **)r r rr-)rr.r/rrrrsz_PyAccess32_4._post_initcCs"|j||}|j|j|j|jfS)N)r-r0r8r9r1)rr$r%r2rrrr'sz_PyAccess32_4.get_pixelcCsR|j||}t|dd|_t|dd|_t|dd|_t|dd|_dS)Nrr3r4r:r)r-r5r0r8r9r1)rr$r%r#r2rrrr!s z_PyAccess32_4.set_pixelN)r)r*r+r6rr'r!rrrrr;sr;c@s(eZdZdZddZddZddZdS) _PyAccess8z' 1, L, P, 8 bit images stored as uint8 cOs |j|_dS)N)rr-)rr.r/rrrrsz_PyAccess8._post_initcCs|j||S)N)r-)rr$r%rrrr'sz_PyAccess8.get_pixelcCsJyt|d|j||<Wn,tk rDt|dd|j||<YnXdS)Nr3r)r5r- TypeError)rr$r%r#rrrr!sz_PyAccess8.set_pixelN)r)r*r+r6rr'r!rrrrr<sr<c@s(eZdZdZddZddZddZdS) _PyAccessI16_Nz2 I;16 access, native bitendian without conversion cOstd|j|_dS)Nzunsigned short **)r r rr-)rr.r/rrrrsz_PyAccessI16_N._post_initcCs|j||S)N)r-)rr$r%rrrr'sz_PyAccessI16_N.get_pixelcCsJyt|d|j||<Wn,tk rDt|dd|j||<YnXdS)Nir)r5r-r=)rr$r%r#rrrr!sz_PyAccessI16_N.set_pixelN)r)r*r+r6rr'r!rrrrr>sr>c@s(eZdZdZddZddZddZdS) _PyAccessI16_Lz I;16L access, with conversion cOstd|j|_dS)Nzstruct Pixel_I16 **)r r rr-)rr.r/rrrrsz_PyAccessI16_L._post_initcCs|j||}|j|jdS)N)r-lr0)rr$r%r2rrrr'sz_PyAccessI16_L.get_pixelcCsX|j||}yt|d}Wn"tk r>t|dd}YnX|d@|_|d?|_dS)Nirr3)r-r5r=rAr0)rr$r%r#r2rrrr!s z_PyAccessI16_L.set_pixelN)r)r*r+r6rr'r!rrrrr?sr?c@s(eZdZdZddZddZddZdS) _PyAccessI16_Bz I;16B access, with conversion cOstd|j|_dS)Nzstruct Pixel_I16 **)r r rr-)rr.r/rrrrsz_PyAccessI16_B._post_initcCs|j||}|jd|jS)Nr@)r-rAr0)rr$r%r2rrrr'sz_PyAccessI16_B.get_pixelcCsX|j||}yt|d}Wn"tk r>t|dd}YnX|d?|_|d@|_dS)NirrBr3)r-r5 ExceptionrAr0)rr$r%r#r2rrrr!s z_PyAccessI16_B.set_pixelN)r)r*r+r6rr'r!rrrrrCsrCc@s(eZdZdZddZddZddZdS) _PyAccessI32_Nz$ Signed Int32 access, native endian cOs |j|_dS)N)rr-)rr.r/rrrrsz_PyAccessI32_N._post_initcCs|j||S)N)r-)rr$r%rrrr'sz_PyAccessI32_N.get_pixelcCs||j||<dS)N)r-)rr$r%r#rrrr! sz_PyAccessI32_N.set_pixelN)r)r*r+r6rr'r!rrrrrEsrEc@s0eZdZdZddZddZddZdd Zd S) _PyAccessI32_Swapz. I;32L/B access, with byteswapping conversion cOs |j|_dS)N)rr-)rr.r/rrrrsz_PyAccessI32_Swap._post_initcCs\td|}td|}|d|d|d|df\|d<|d<|d<|d<td|dS)Nzint *zunsigned char *rr:r4r)r newr )riorigcharsrrrreverses  4z_PyAccessI32_Swap.reversecCs||j||S)N)rKr-)rr$r%rrrr'sz_PyAccessI32_Swap.get_pixelcCs|||j||<dS)N)rKr-)rr$r%r#rrrr!sz_PyAccessI32_Swap.set_pixelN)r)r*r+r6rrKr'r!rrrrrF s rFc@s(eZdZdZddZddZddZdS) _PyAccessFz 32 bit float access cOstd|j|_dS)Nzfloat **)r r rr-)rr.r/rrrr#sz_PyAccessF._post_initcCs|j||S)N)r-)rr$r%rrrr'&sz_PyAccessF.get_pixelcCs>y||j||<Wn&tk r8|d|j||<YnXdS)Nr)r-r=)rr$r%r#rrrr!)sz_PyAccessF.set_pixelN)r)r*r+r6rr'r!rrrrrL srL)1LrZLAZLaZPAZRGBZLABZHSVZYCbCrZRGBAZRGBaZRGBXZCMYKFIlittlezI;16zI;16LzI;16BzI;32LzI;32BFcCs.t|jd}|s$td|jdS|||S)NzPyAccess Not Implemented: %s)mode_mapgetrloggerdebug)rr Z access_typerrrrGUs rG)F)loggingsysZcffir getLoggerr)rTZdefsr Zcdefrr,r7r;r<r>r?rCrErFrLrR byteorderrGrrrrsZ   P