
 Xc           @   s   d  d l  Z  d  d l m Z d d d     YZ d d d     YZ d d d     YZ d	 d d
     YZ d e f d     YZ d S(   iN(   t   Imaget   HDCc           B   s    e  Z d  Z d   Z d   Z RS(   s   
    Wraps an HDC integer. The resulting object can be passed to the
    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
    methods.
    c         C   s   | |  _  d  S(   N(   t   dc(   t   selfR   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __init__   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __int__!   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR      s   	t   HWNDc           B   s    e  Z d  Z d   Z d   Z RS(   s   
    Wraps an HWND integer. The resulting object can be passed to the
    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`
    methods, instead of a DC.
    c         C   s   | |  _  d  S(   N(   t   wnd(   R   R
   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   +   s    c         C   s   |  j  S(   N(   R
   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   .   s    (   R   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR	   %   s   	t   Dibc           B   sh   e  Z d  Z d
 d  Z d   Z d
 d  Z d   Z d
 d  Z d   Z	 d   Z
 d   Z d	   Z RS(   s&  
    A Windows bitmap with the given mode and size.  The mode can be one of "1",
    "L", "P", or "RGB".

    If the display requires a palette, this constructor creates a suitable
    palette and associates it with the image. For an "L" image, 128 greylevels
    are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together
    with 20 greylevels.

    To make sure that palettes work properly under Windows, you must call the
    **palette** method upon certain events from Windows.

    :param image: Either a PIL image, or a mode string. If a mode string is
                  used, a size must also be given.  The mode can be one of "1",
                  "L", "P", or "RGB".
    :param size: If the first argument is a mode string, this
                 defines the size of the image.
    c         C   s   t  | d  r3 t  | d  r3 | j } | j } n | } d  } | d k r] t j |  } n  t j j | |  |  _ | |  _ | |  _ | r |  j	 |  n  d  S(   Nt   modet   sizet   1t   Lt   Pt   RGB(   R   R   R   R   (
   t   hasattrR   R   t   NoneR    t   getmodebaset   coret   displayt   imaget   paste(   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   F   s    			c         C   sg   t  | t  rQ |  j j |  } z |  j j |  } Wd |  j j | |  Xn |  j j |  } | S(   s)  
        Copy the bitmap contents to a device context.

        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.  In PythonWin, you can use the
                       :py:meth:`CDC.GetHandleAttrib` to get a suitable handle.
        N(   t
   isinstanceR	   R   t   getdct   exposet	   releasedc(   R   t   handleR   t   result(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   U   s    c         C   s   | s d |  j  } n  t | t  rm |  j j |  } z |  j j | | |  } Wd |  j j | |  Xn |  j j | | |  } | S(   sm  
        Same as expose, but allows you to specify where to draw the image, and
        what part of it to draw.

        The destination and source areas are given as 4-tuple rectangles. If
        the source is omitted, the entire image is copied. If the source and
        the destination have different sizes, the image is resized as
        necessary.
        i    N(   i    i    (   R   R   R	   R   R   t   drawR   (   R   R   t   dstt   srcR   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   g   s    
c         C   sg   t  | t  rQ |  j j |  } z |  j j |  } Wd |  j j | |  Xn |  j j |  } | S(   se  
        Installs the palette associated with the image in the given device
        context.

        This method should be called upon **QUERYNEWPALETTE** and
        **PALETTECHANGED** events from Windows. If this method returns a
        non-zero value, one or more display palette entries were changed, and
        the image should be redrawn.

        :param handle: Device context (HDC), cast to a Python integer, or an
                       HDC or HWND instance.
        :return: A true value if one or more entries were changed (this
                 indicates that the image should be redrawn).
        N(   R   R	   R   R   t   query_paletteR   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR"   }   s    c         C   sg   | j    |  j | j k r1 | j |  j  } n  | rP |  j j | j |  n |  j j | j  d S(   s  
        Paste a PIL image into the bitmap image.

        :param im: A PIL image.  The size must match the target region.
                   If the mode does not match, the image is converted to the
                   mode of the bitmap image.
        :param box: A 4-tuple defining the left, upper, right, and
                    lower pixel coordinate.  If None is given instead of a
                    tuple, all of the image is assumed.
        N(   t   loadR   t   convertR   R   t   im(   R   R%   t   box(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR      s    
c         C   s   |  j  j |  S(   s   
        Load display memory contents from byte data.

        :param buffer: A buffer containing display data (usually
                       data returned from <b>tobytes</b>)
        (   R   t	   frombytes(   R   t   buffer(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR'      s    c         C   s   |  j  j   S(   sy   
        Copy display memory contents to bytes object.

        :return: A bytes object containing display data.
        (   R   t   tobytes(   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR)      s    c         O   s&   t  j d t d d |  j | |   S(   Ns<   fromstring() is deprecated. Please call frombytes() instead.t
   stackleveli   (   t   warningst   warnt   DeprecationWarningR'   (   R   t   argst   kw(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt
   fromstring   s
    c         C   s    t  j d t d d |  j   S(   Ns8   tostring() is deprecated. Please call tobytes() instead.R*   i   (   R+   R,   R-   R)   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   tostring   s
    N(   R   R   R   R   R   R   R   R"   R   R'   R)   R0   R1   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR   2   s   						t   Windowc           B   sY   e  Z d  d	 d	 d  Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(
   t   PILc         C   s1   t  j j | |  j | p d | p$ d  |  _ d  S(   Ni    (   R    R   t   createwindowt   _Window__dispatchert   hwnd(   R   t   titlet   widtht   height(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR      s    	c         G   s   t  |  d |  |   S(   Nt
   ui_handle_(   t   getattr(   R   t   actionR.   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   __dispatcher   s    c         C   s   d  S(   N(    (   R   R   t   x0t   y0t   x1t   y1(    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_clear   s    c         C   s   d  S(   N(    (   R   R>   R?   R@   RA   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_damage   s    c         C   s   d  S(   N(    (   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_destroy   s    c         C   s   d  S(   N(    (   R   R   R>   R?   R@   RA   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_repair   s    c         C   s   d  S(   N(    (   R   R8   R9   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   ui_handle_resize   s    c         C   s   t  j j   d  S(   N(   R    R   t	   eventloop(   R   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   mainloop   s    N(   R   R   R   R   R5   RB   RC   RD   RE   RF   RH   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR2      s   						t   ImageWindowc           B   s   e  Z d  d  Z d   Z RS(   R3   c         C   sV   t  | t  s t |  } n  | |  _ | j \ } } t j |  | d | d | d  S(   NR8   R9   (   R   R   R   R   R2   R   (   R   R   R7   R8   R9   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyR      s
    	c         C   s#   |  j  j | | | | | f  d  S(   N(   R   R   (   R   R   R>   R?   R@   RA   (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyRE      s    (   R   R   R   RE   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyRI      s   (    (    (    (    (   R+   R3   R    R   R	   R   R2   RI   (    (    (    s0   /usr/lib/python2.7/dist-packages/PIL/ImageWin.pyt   <module>   s    