ó
î Xc           @  s5  d  d l  m Z d  d l m Z d  d l Z d Z d Z e ƒ  Z e j e ƒ d e	 f d „  ƒ  YZ
 d e
 f d	 „  ƒ  YZ d
 e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d e
 f d „  ƒ  YZ i e d 6e d 6e d 6e d 6e d  6e d! 6e d" 6e d# 6e d$ 6e d% 6e d& 6e d' 6e d( 6e d) 6e d* 6Z e j d+ k róe e d, <e e d- <e e d. <e e d/ <e e d0 <n2 e e d, <e e d- <e e d. <e e d/ <e e d0 <e d1 „ Z d S(2   iÿÿÿÿ(   t   print_function(   t   FFINi    s`   
struct Pixel_RGBA {
    unsigned char r,g,b,a;
};
struct Pixel_I16 {
    unsigned char l,r;
};
t   PyAccessc           B  sD   e  Z e d  „ Z d „  Z d „  Z d „  Z e Z e Z d „  Z	 RS(   c         C  s¡   t  | j j ƒ } | |  _ t j d | d ƒ |  _ t j d | d ƒ |  _ t j d | d ƒ |  _ | d |  _	 | d |  _
 t r“ t | ƒ n  |  j ƒ  d  S(   Ns   unsigned char **t   image8s   int **t   image32t   imaget   xsizet   ysize(   t   dictt   imt   unsafe_ptrst   readonlyt   ffit   castR   R   R   R   R   t   DEBUGt   printt
   _post_init(   t   selft   imgR   t   vals(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyt   __init__,   s    	c           C  s   d  S(   N(    (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   9   s    c         C  s@   |  j  r t d ƒ ‚ n  |  j | ƒ \ } } |  j | | | ƒ S(   s  
        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).
        :param value: The pixel value.
        s%   Attempt to putpixel a read only image(   R   t
   ValueErrort   check_xyt	   set_pixel(   R   t   xyt   colort   xt   y(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyt   __setitem__<   s    		c         C  s%   |  j  | ƒ \ } } |  j | | ƒ S(   sÙ   
        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).
        (   R   t	   get_pixel(   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyt   __getitem__J   s    	c         C  s]   | \ } } d | k o& |  j  k  n oG d | k oE |  j k  n sY t d ƒ ‚ n  | S(   Ni    s   pixel location out of range(   R   R   R   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   Y   s    >(
   t   __name__t
   __module__t   FalseR   R   R   R   t   putpixelt   getpixelR   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   *   s   			t   _PyAccess32_2c           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s9    PA, LA, stored in first and last bytes of a 32 bit word c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   struct Pixel_RGBA **(   R   R   R   t   pixels(   R   t   argst   kwargs(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   b   s    c         C  s!   |  j  | | } | j | j f S(   N(   R%   t   rt   a(   R   R   R   t   pixel(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   e   s    c         C  sA   |  j  | | } t | d d ƒ | _ t | d d ƒ | _ d  S(   Ni    iÿ   i   (   R%   t   minR(   R)   (   R   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   i   s    (   R   R    t   __doc__R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR$   `   s   		t   _PyAccess32_3c           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sC    RGB and friends, stored in the first three bytes of a 32 bit word c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   struct Pixel_RGBA **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   s   s    c         C  s'   |  j  | | } | j | j | j f S(   N(   R%   R(   t   gt   b(   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   v   s    c         C  sW   |  j  | | } t | d d ƒ | _ t | d d ƒ | _ t | d d ƒ | _ d  S(   Ni    iÿ   i   i   (   R%   R+   R(   R.   R/   (   R   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   z   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR-   p   s   		t   _PyAccess32_4c           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s(    RGBA etc, all 4 bytes of a 32 bit word c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   struct Pixel_RGBA **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   „   s    c         C  s-   |  j  | | } | j | j | j | j f S(   N(   R%   R(   R.   R/   R)   (   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ‡   s    c         C  sm   |  j  | | } t | d d ƒ | _ t | d d ƒ | _ t | d d ƒ | _ t | d d ƒ | _ d  S(   Ni    iÿ   i   i   i   (   R%   R+   R(   R.   R/   R)   (   R   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ‹   s
    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR0   ‚   s   		t
   _PyAccess8c           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s'    1, L, P, 8 bit images stored as uint8 c         O  s   |  j  |  _ d  S(   N(   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   –   s    c         C  s   |  j  | | S(   N(   R%   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ™   s    c         C  sJ   y t  | d ƒ |  j | | <Wn% t  | d d ƒ |  j | | <n Xd  S(   Niÿ   i    (   R+   R%   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   œ   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR1   ”   s   		t   _PyAccessI16_Nc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s2    I;16 access, native bitendian without conversion c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   unsigned short **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   §   s    c         C  s   |  j  | | S(   N(   R%   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ª   s    c         C  sJ   y t  | d ƒ |  j | | <Wn% t  | d d ƒ |  j | | <n Xd  S(   Niÿÿ  i    (   R+   R%   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ­   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR2   ¥   s   		t   _PyAccessI16_Lc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s    I;16L access, with conversion c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   struct Pixel_I16 **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ¸   s    c         C  s#   |  j  | | } | j | j d S(   Ni   (   R%   t   lR(   (   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   »   s    c         C  s_   |  j  | | } y t | d ƒ } Wn t | d d ƒ } n X| d @| _ | d ?| _ d  S(   Niÿÿ  i    iÿ   i   (   R%   R+   R4   R(   (   R   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ¿   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR3   ¶   s   		t   _PyAccessI16_Bc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s    I;16B access, with conversion c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   struct Pixel_I16 **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   Ì   s    c         C  s#   |  j  | | } | j d | j S(   Ni   (   R%   R4   R(   (   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   Ï   s    c         C  s_   |  j  | | } y t | d ƒ } Wn t | d d ƒ } n X| d ?| _ | d @| _ d  S(   Niÿÿ  i    i   iÿ   (   R%   R+   R4   R(   (   R   R   R   R   R*   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   Ó   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR5   Ê   s   		t   _PyAccessI32_Nc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s$    Signed Int32 access, native endian c         O  s   |  j  |  _ d  S(   N(   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   à   s    c         C  s   |  j  | | S(   N(   R%   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ã   s    c         C  s   | |  j  | | <d  S(   N(   R%   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   æ   s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR6   Þ   s   		t   _PyAccessI32_Swapc           B  s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s.    I;32L/B access, with byteswapping conversion c         O  s   |  j  |  _ d  S(   N(   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ì   s    c         C  sv   t  j d | ƒ } t  j d | ƒ } | d | d | d | d f \ | d <| d <| d <| d <t  j d | ƒ d S(   Ns   int *s   unsigned char *i   i   i   i    (   R   t   newR   (   R   t   it   origt   chars(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyt   reverseï   s
    0c         C  s   |  j  |  j | | ƒ S(   N(   R<   R%   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ö   s    c         C  s   |  j  | ƒ |  j | | <d  S(   N(   R<   R%   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ù   s    (   R   R    R,   R   R<   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR7   ê   s
   			t
   _PyAccessFc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s    32 bit float access c         O  s   t  j d |  j ƒ |  _ d  S(   Ns   float **(   R   R   R   R%   (   R   R&   R'   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR   ÿ   s    c         C  s   |  j  | | S(   N(   R%   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR     s    c         C  s8   y | |  j  | | <Wn | d |  j  | | <n Xd  S(   Ni    (   R%   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR     s    (   R   R    R,   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR=   ý   s   		t   1t   Lt   Pt   LAt   PAt   RGBt   LABt   HSVt   YCbCrt   RGBAt   RGBat   RGBXt   CMYKt   Ft   It   littles   I;16s   I;16Ls   I;16Bs   I;32Ls   I;32Bc         C  s`   t  j |  j d  ƒ } | s9 t r5 t d |  j ƒ n  d  St rS t d |  j ƒ n  | |  | ƒ S(   Ns   PyAccess Not Implemented: %ss   New PyAccess: %s(   t   mode_mapt   gett   modet   NoneR   R   (   R   R   t   access_type(    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyR8   /  s    (   t
   __future__R    t   cffiR   t   sysR   t   defsR   t   cdeft   objectR   R$   R-   R0   R1   R2   R3   R5   R6   R7   R=   RN   t	   byteorderR!   R8   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/PyAccess.pyt   <module>   sX   		6










