Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/PIL/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/PIL/__pycache__/ImageWin.cpython-35.pyc



�ʴWp�@s�ddlmZGdd�de�ZGdd�de�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZdS)
�)�Imagec@s.eZdZdZdd�Zdd�ZdS)�HDCz�
    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.
    cCs
||_dS)N)�dc)�selfr�r�?/opt/alt/python35/lib64/python3.5/site-packages/PIL/ImageWin.py�__init__szHDC.__init__cCs|jS)N)r)rrrr�__int__ szHDC.__int__N)�__name__�
__module__�__qualname__�__doc__rr	rrrrrsrc@s.eZdZdZdd�Zdd�ZdS)�HWNDz�
    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.
    cCs
||_dS)N)�wnd)rrrrrr*sz
HWND.__init__cCs|jS)N)r)rrrrr	-szHWND.__int__N)r
rrr
rr	rrrrr$src@s�eZdZdZddd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�Diba&
    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.
    NcCs�t|d�r3t|d�r3|j}|j}n|}d}|dkrZtj|�}tjj||�|_||_||_|r�|j|�dS)N�mode�size�1�L�P�RGB)rrrr)	�hasattrrrrZgetmodebase�core�display�image�paste)rrrrrrrrEs			zDib.__init__cCsgt|t�rQ|jj|�}z|jj|�}Wd|jj||�Xn|jj|�}|S)a)
        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)�
isinstancerr�getdc�expose�	releasedc)r�handler�resultrrrrTsz
Dib.exposecCs�|sd|j}t|t�rj|jj|�}z|jj|||�}Wd|jj||�Xn|jj|||�}|S)am
        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.
        rN)rr)rrrrr�drawr)rr �dst�srcrr!rrrr"fs

zDib.drawcCsgt|t�rQ|jj|�}z|jj|�}Wd|jj||�Xn|jj|�}|S)ae
        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)rrrr�
query_paletter)rr r!rrrr%|szDib.query_palettecCsd|j�|j|jkr.|j|j�}|rM|jj|j|�n|jj|j�dS)a�
        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)�loadr�convertrr�im)rr(Zboxrrrr�s
z	Dib.pastecCs|jj|�S)z�
        Load display memory contents from byte data.

        :param buffer: A buffer containing display data (usually
                       data returned from <b>tobytes</b>)
        )r�	frombytes)r�bufferrrrr)�sz
Dib.frombytescCs
|jj�S)zy
        Copy display memory contents to bytes object.

        :return: A bytes object containing display data.
        )r�tobytes)rrrrr+�szDib.tobytescOstdd��dS)Nzfromstring() has been removed. zPlease use frombytes() instead.)�NotImplementedError)r�args�kwrrr�
fromstring�szDib.fromstringcOstdd��dS)Nztostring() has been removed. zPlease use tobytes() instead.)r,)rr-r.rrr�tostring�szDib.tostring)
r
rrr
rrr"r%rr)r+r/r0rrrrr1s	rc@seZdZdZddddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�Windowz*Create a Window with the given title size.�PILNcCs1tjj||j|pd|p$d�|_dS)Nr)rrZcreatewindow�_Window__dispatcherZhwnd)r�title�width�heightrrrr�s	zWindow.__init__cGst|d|�|�S)NZ
ui_handle_)�getattr)r�actionr-rrrZ__dispatcher�szWindow.__dispatchercCsdS)Nr)rr�x0�y0�x1�y1rrr�ui_handle_clear�szWindow.ui_handle_clearcCsdS)Nr)rr9r:r;r<rrr�ui_handle_damage�szWindow.ui_handle_damagecCsdS)Nr)rrrr�ui_handle_destroy�szWindow.ui_handle_destroycCsdS)Nr)rrr9r:r;r<rrr�ui_handle_repair�szWindow.ui_handle_repaircCsdS)Nr)rr5r6rrr�ui_handle_resize�szWindow.ui_handle_resizecCstjj�dS)N)rrZ	eventloop)rrrr�mainloop�szWindow.mainloop)r
rrr
rr3r=r>r?r@rArBrrrrr1�sr1c@s1eZdZdZddd�Zdd�ZdS)�ImageWindowz6Create an image window which displays the given image.r2cCsSt|t�st|�}||_|j\}}tj||d|d|�dS)Nr5r6)rrrrr1r)rrr4r5r6rrrr�s
	zImageWindow.__init__cCs#|jj|||||f�dS)N)rr")rrr9r:r;r<rrrr@�szImageWindow.ui_handle_repairN)r
rrr
rr@rrrrrC�srCN)r2r�objectrrrr1rCrrrr�<module>s


�