o
     ¼ÎhÄ  ã                   @  sŽ   d dl mZ d dlZd dlmZ d dlmZ ddlmZm	Z	 dZ
e
r(ddlmZ ddd„Zd dd„ZG dd„ dƒZG dd„ dƒZd!dd„ZdS )"é    )ÚannotationsN)ÚBytesIO)ÚAnyé   )ÚImageÚ	ImageFileF)ÚCapsuleTypeÚkwúdict[str, Any]ÚreturnúImageFile.ImageFile | Nonec                 C  s@   d }d| v r|   d¡}nd| v rt|   d¡ƒ}|sd S t |¡S )NÚfileÚdata)Úpopr   r   Úopen)r	   Úsource© r   úQ/home/www/facesmatcher.com/frenv_anti/lib/python3.10/site-packages/PIL/ImageTk.pyÚ_get_image_from_kw+   s   
r   ÚcommandÚstrÚphotoúPhotoImage | tkinter.PhotoImageÚptrr   ÚNonec              	   C  sb   |j }z| | |t|ƒ¡ W d S  tjy0   ddlm} | | ¡ ¡ | | |t|ƒ¡ Y d S w )Nr   )Ú
_imagingtk)	ÚtkÚcallÚreprÚtkinterZTclErrorÚ r   ZtkinitZ
interpaddr)r   r   r   r   r   r   r   r   Ú_pyimagingtkcall6   s   úr!   c                   @  sR   e Zd ZdZ		dddd„Zddd„Zddd„Zddd„Zddd„Zd dd„Z	dS )!Ú
PhotoImagea3  
    A Tkinter-compatible photo image.  This can be used
    everywhere Tkinter expects an image object.  If the image is an RGBA
    image, pixels having alpha 0 are treated as transparent.

    The constructor takes either a PIL image, or a mode and a size.
    Alternatively, you can use the ``file`` or ``data`` options to initialize
    the photo image object.

    :param image: Either a PIL image, or a mode string.  If a mode string is
                  used, a size must also be given.
    :param size: If the first argument is a mode string, this defines the size
                 of the image.
    :keyword file: A filename to load the image from (using
                   ``Image.open(file)``).
    :keyword data: An 8-bit string containing image data (as loaded from an
                   image file).
    NÚimageúImage.Image | str | NoneÚsizeútuple[int, int] | Noner	   r   r   r   c                 K  sâ   |d u rt |ƒ}|d u rd}t|ƒ‚t|tƒr&|}d }|d u r%d}t|ƒ‚n#|j}|dkr>| ¡  | ¡  |jr<|jjnd}|j}|\|d< |d< |dvrRt	 
|¡}|| _|| _tjdi |¤Ž| _| jj| _|ro|  |¡ d S d S )	NúImage is requiredz+If first argument is mode, size is requiredÚPÚRGBÚwidthÚheight)Ú1ÚLr)   ÚRGBAr   )r   Ú
ValueErrorÚ
isinstancer   ÚmodeZapply_transparencyÚloadÚpaletter%   r   ZgetmodebaseÚ_PhotoImage__modeÚ_PhotoImage__sizer   r"   Ú_PhotoImage__photor   Úpaste)Úselfr#   r%   r	   Úmsgr1   r   r   r   Ú__init__]   s8   
þ

ÿzPhotoImage.__init__c                 C  óX   z| j j}W n
 ty   Y d S w d | j _z| j j dd|¡ W d S  ty+   Y d S w ©Nr#   Údelete)r6   ÚnameÚAttributeErrorr   r   Ú	Exception©r8   r>   r   r   r   Ú__del__†   ó   ÿÿzPhotoImage.__del__r   c                 C  ó
   t | jƒS )zô
        Get the Tkinter photo image identifier.  This method is automatically
        called by Tkinter whenever a PhotoImage object is passed to a Tkinter
        method.

        :return: A Tkinter photo image identifier (a string).
        )r   r6   ©r8   r   r   r   Ú__str__‘   ó   
zPhotoImage.__str__Úintc                 C  ó
   | j d S ©zU
        Get the width of the image.

        :return: The width, in pixels.
        r   ©r5   rE   r   r   r   r*   ›   ó   
zPhotoImage.widthc                 C  rI   ©zW
        Get the height of the image.

        :return: The height, in pixels.
        r   rK   rE   r   r   r   r+   £   rL   zPhotoImage.heightÚimúImage.Imagec                 C  sX   |  ¡ }|j}| ¡ r|j| jkr#tj | j|j¡}| 	||¡ |j
}td| j|ƒ dS )aF  
        Paste a PIL image into the photo image.  Note that this can
        be very slow if the photo image is displayed.

        :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.
        ZPyImagingPhotoN)ÚgetimrN   Zisblockr1   r4   r   ÚcoreZ	new_blockr%   Zconvert2r   r!   r6   )r8   rN   r   r#   Úblockr   r   r   r7   «   s   
zPhotoImage.paste)NN)r#   r$   r%   r&   r	   r   r   r   ©r   r   ©r   r   ©r   rH   )rN   rO   r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r:   rB   rF   r*   r+   r7   r   r   r   r   r"   I   s    ý
)



r"   c                   @  sD   e Zd ZdZddd	d
„Zddd„Zddd„Zddd„Zddd„ZdS )ÚBitmapImageaä  
    A Tkinter-compatible bitmap image.  This can be used everywhere Tkinter
    expects an image object.

    The given image must have mode "1".  Pixels having value 0 are treated as
    transparent.  Options, if any, are passed on to Tkinter.  The most commonly
    used option is ``foreground``, which is used to specify the color for the
    non-transparent parts.  See the Tkinter documentation for information on
    how to specify colours.

    :param image: A PIL image.
    Nr#   úImage.Image | Noner	   r   r   r   c                 K  sR   |d u rt |ƒ}|d u rd}t|ƒ‚|j| _|j| _tjdd| ¡ i|¤Ž| _	d S )Nr'   r   r   )
r   r/   r1   Z_BitmapImage__moder%   Ú_BitmapImage__sizer   rZ   ZtobitmapÚ_BitmapImage__photo)r8   r#   r	   r9   r   r   r   r:   Ñ   s   zBitmapImage.__init__c                 C  r;   r<   )r]   r>   r?   r   r   r@   rA   r   r   r   rB   Þ   rC   zBitmapImage.__del__rH   c                 C  rI   rJ   ©r\   rE   r   r   r   r*   é   rL   zBitmapImage.widthc                 C  rI   rM   r^   rE   r   r   r   r+   ñ   rL   zBitmapImage.heightr   c                 C  rD   )z÷
        Get the Tkinter bitmap image identifier.  This method is automatically
        called by Tkinter whenever a BitmapImage object is passed to a Tkinter
        method.

        :return: A Tkinter bitmap image identifier (a string).
        )r   r]   rE   r   r   r   rF   ù   rG   zBitmapImage.__str__)N)r#   r[   r	   r   r   r   rS   rU   rT   )	rV   rW   rX   rY   r:   rB   r*   r+   rF   r   r   r   r   rZ   Ã   s    


rZ   rO   c                 C  s,   t  d|  ¡ |  ¡ f¡}td| | ¡ ƒ |S )z:Copies the contents of a PhotoImage to a PIL image memory.r.   ZPyImagingPhotoGet)r   Únewr*   r+   r!   rP   )r   rN   r   r   r   Úgetimage  s   r`   )r	   r
   r   r   )r   r   r   r   r   r   r   r   )r   r"   r   rO   )Ú
__future__r   r   Úior   Útypingr   r    r   r   ÚTYPE_CHECKINGZ_typingr   r   r!   r"   rZ   r`   r   r   r   r   Ú<module>   s   

zA