CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
ImageWin.cpython-310.pyc134 linesDownload Raw Back to __pycache__
1o

2��Yi� �@sdddlmZddlmZGdd�d�ZGdd�d�ZGdd	�d	�ZGd3d�d�ZGdd
�d
e�ZdS)�)�annotations�)�Imagec@�$eZdZdZddd�Zddd	�Zd4S)
�HDCz�5    Wraps an HDC integer. The resulting object can be passed to the6    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`7    methods.8    �dc�int�return�NonecC�9||_dS�N�r)�selfr�r�vE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\PIL/ImageWin.py�__init__�10zHDC.__init__cC�|jSrr
�rrrr�__int__"�zHDC.__int__N)rrr	r11�r	r��__name__�12__module__�__qualname__�__doc__rrrrrrr�13rc@r)
�HWNDz�14    Wraps an HWND integer. The resulting object can be passed to the15    :py:meth:`~PIL.ImageWin.Dib.draw` and :py:meth:`~PIL.ImageWin.Dib.expose`16    methods, instead of a DC.17    �wndrr	r18cCrr�r)rrrrrr-rz
HWND.__init__cCrrr rrrrr0rzHWND.__int__N)rrr	r19rrrrrrr&rrc@sbeZdZdZ	d#d$d	d20�Zd%d
d�Z	d#d&dd�Zd'dd�Z	d#d(dd�Zd)dd �Z	d*d!d"�Z21dS)+�Diba&22    A Windows bitmap with the given mode and size.  The mode can be one of "1",23    "L", "P", or "RGB".24 25    If the display requires a palette, this constructor creates a suitable26    palette and associates it with the image. For an "L" image, 128 graylevels27    are allocated. For an "RGB" image, a 6x6x6 colour cube is used, together28    with 20 graylevels.29 30    To make sure that palettes work properly under Windows, you must call the31    ``palette`` method upon certain events from Windows.32 33    :param image: Either a PIL image, or a mode string. If a mode string is34                  used, a size must also be given.  The mode can be one of "1",35                  "L", "P", or "RGB".36    :param size: If the first argument is a mode string, this37                 defines the size of the image.38    N�image�Image.Image | str�size�tuple[int, int] | Noner	r39cCs�t|t�r|}d}|durd}t|��n|j}|j}|dvr#t�|�}tj�||�|_	||_||_|rAt|t�r:J�|�40|�dSdS)N�z+If first argument is mode, size is required)�1�L�P�RGB)�41isinstance�str�42ValueError�moder$rZgetmodebase�core�displayr"�paste)rr"r$r.�msgrrrrHs$43�44�zDib.__init__�handle�int | HDC | HWNDc45Cs`t|�}t|t�r(|j�|�}z|j�|�W|j�||�dS|j�||�w|j�|�dS)a 46        Copy the bitmap contents to a device context.47 48        :param handle: Device context (HDC), cast to a Python integer, or an49                       HDC or HWND instance.  In PythonWin, you can use50                       ``CDC.GetHandleAttrib()`` to get a suitable handle.51        N)rr+rr"�getdc�expose�	releasedc)rr3�52handle_intrrrrr6]s53"z54Dib.expose�dst�tuple[int, int, int, int]�src� tuple[int, int, int, int] | Nonec55Csz|dur	d|j}t|�}t|t�r3|j�|�}z|j�|||�W|j�||�dS|j�||�w|j�|||�dS)am56        Same as expose, but allows you to specify where to draw the image, and57        what part of it to draw.58 59        The destination and source areas are given as 4-tuple rectangles. If60        the source is omitted, the entire image is copied. If the source and61        the destination have different sizes, the image is resized as62        necessary.63        N)rr)r$rr+rr"r5�drawr7)rr3r9r;r8rrrrr=os6465"zDib.drawrc66Cs`t|�}t|t�r(|j�|�}z|j�|�}W|j�||�|S|j�||�w|j�|�}|S)at67        Installs the palette associated with the image in the given device68        context.69 70        This method should be called upon **QUERYNEWPALETTE** and71        **PALETTECHANGED** events from Windows. If this method returns a72        non-zero value, one or more display palette entries were changed, and73        the image should be redrawn.74 75        :param handle: Device context (HDC), cast to a Python integer, or an76                       HDC or HWND instance.77        :return: The number of entries that were changed (if one or more entries,78                 this indicates that the image should be redrawn).79        )rr+rr"r5�
query_paletter7)rr3r8�resultrrrr>�s80�zDib.query_palette�im�Image.Image�boxcCsJ|��|j|jkr|�|j�}|r|j�|j|�dS|j�|j�dS)a�81        Paste a PIL image into the bitmap image.82 83        :param im: A PIL image.  The size must match the target region.84                   If the mode does not match, the image is converted to the85                   mode of the bitmap image.86        :param box: A 4-tuple defining the left, upper, right, and87                    lower pixel coordinate.  See :ref:`coordinate-system`. If88                    None is given instead of a tuple, all of the image is89                    assumed.90        N)�loadr.�convertr"r1r@)rr@rBrrrr1�sz	Dib.paste�buffer�bytescCs|j�|�dS)z�91        Load display memory contents from byte data.92 93        :param buffer: A buffer containing display data (usually94                       data returned from :py:func:`~PIL.ImageWin.Dib.tobytes`)95        N)r"�	frombytes)rrErrrrG�sz
Dib.frombytescCs96|j��S)zy97        Copy display memory contents to bytes object.98 99        :return: A bytes object containing display data.100        )r"�tobytesrrrrrH�s101zDib.tobytesr)r"r#r$r%r	r102)r3r4r	r103)r3r4r9r:r;r<r	r104)r3r4r	r)r@rArBr<r	r105)rErFr	r106)r	rF)rrrrrr6r=r>r1rGrHrrrrr!4s�107�108�109	r!c@sdeZdZdZ	d#d$dd�Zd%dd�Zd&dd�Zd'dd�Zd(dd�Zd&dd�Z	d)dd �Z110d(d!d"�ZdS)*�Windowz*Create a Window with the given title size.�PILN�titler,�width�111int | None�heightr	r112cCs"tj�||j|p	d|pd�|_dS)Nr)rr/Zcreatewindow�_Window__dispatcherZhwnd)rrKrLrNrrrr�s113�zWindow.__init__�action�argsrcGst|d|���|�dS)NZ114ui_handle_)�getattr)rrPrQrrrZ__dispatcher�szWindow.__dispatcherr�x0�y0�x1�y1cC�dSrr�rrrSrTrUrVrrr�ui_handle_clear��zWindow.ui_handle_clearcCrWrr)rrSrTrUrVrrr�ui_handle_damage�rZzWindow.ui_handle_damagecCrWrrrrrr�ui_handle_destroy�rZzWindow.ui_handle_destroycCrWrrrXrrr�ui_handle_repair�rZzWindow.ui_handle_repaircCrWrr)rrLrNrrr�ui_handle_resize�rZzWindow.ui_handle_resizecCstj��dSr)rr/Z	eventlooprrrr�mainloop�szWindow.mainloop)rJNN)rKr,rLrMrNrMr	r115)rPr,rQrr	r116�rrrSrrTrrUrrVrr	r117)118rSrrTrrUrrVrr	r119)r	r120)rLrrNrr	r121)rrrrrrOrYr[r\r]r^r_rrrrrI�s�122123124125126127rIcs.eZdZdZdd�fd	d128�
Zddd�Z�ZS)�ImageWindowz6Create an image window which displays the given image.rJr"�Image.Image | DibrKr,r	r129cs8t|t�s	t|�}||_|j\}}t�j|||d�dS)N)rLrN)r+r!r"r$�superr)rr"rKrLrN��	__class__rrr�s130131132zImageWindow.__init__rrrSrTrUrVcCs|j�|||||f�dSr)r"r=rXrrrr]�szImageWindow.ui_handle_repair)rJ)r"rbrKr,r	r133r`)rrrrrr]�
__classcell__rrrdrra�sraN)	�134__future__rr&rrrr!rIrarrrr�<module>s 
Aluode/PerceptionLabPortable · CoolFace