o
    h
                     @   sT   d Z ddlZddlZddlmZ G dd deZG dd deZG d	d
 d
eZdS )zD
PIL-based formats to take screenshots and grab from the clipboard.
    N   )Formatc                       sJ   e Zd ZdZdZdZ fddZdd Zdd	 ZG d
d de	j
Z
  ZS )BaseGrabFormatzBase format for grab formats.FNc                    s$   t t| j|i | t | _d S N)superr   __init__	threadingRLock_lock)selfargskwargs	__class__ O/var/www/html/scripts/venv/lib/python3.10/site-packages/imageio/plugins/grab.pyr      s   zBaseGrabFormat.__init__c                 C   s   dS )NFr   r   requestr   r   r   
_can_write      zBaseGrabFormat._can_writec              	   C   s   | j B | js<d| _dd l}t|dstdzddlm} W n ty/   Y W d    d S w || _W d    | jS W d    | jS 1 sHw   Y  | jS )NTr   __version__z(Imageio Pillow requires Pillow, not PIL!)	ImageGrab)r
   _pillow_importedPILhasattrImportErrorr   
_ImageGrab)r   r   r   r   r   r   _init_pillow   s(   
	

zBaseGrabFormat._init_pillowc                   @   s$   e Zd Zdd Zdd Zdd ZdS )zBaseGrabFormat.Readerc                 C      d S r   r   r   r   r   r   _open)   r   zBaseGrabFormat.Reader._openc                 C   r   r   r   r   r   r   r   _close,   r   zBaseGrabFormat.Reader._closec                 C   s   | j |S r   )format	_get_data)r   indexr   r   r   r#   /   s   zBaseGrabFormat.Reader._get_dataN)__name__
__module____qualname__r    r!   r#   r   r   r   r   Reader(   s    r(   )r%   r&   r'   __doc__r   r   r   r   r   r   r(   __classcell__r   r   r   r   r      s    r   c                   @       e Zd ZdZdd Zdd ZdS )ScreenGrabFormata  The ScreenGrabFormat provided a means to grab screenshots using
    the uri of "<screen>".

    This functionality is provided via Pillow. Note that "<screen>" is
    only supported on Windows and OS X.

    Parameters for reading
    ----------------------
    No parameters.
    c                 C      |j dkrdS t|  S )Nz<screen>Ffilenameboolr   r   r   r   r   	_can_read?      
zScreenGrabFormat._can_readc                 C   s6   |   }|sJ | }|d usJ t|}|i fS r   )r   grabnpasarrayr   r$   r   pil_imimr   r   r   r#   D   s   
zScreenGrabFormat._get_dataNr%   r&   r'   r)   r1   r#   r   r   r   r   r,   3       r,   c                   @   r+   )ClipboardGrabFormata(  The ClipboardGrabFormat provided a means to grab image data from
    the clipboard, using the uri "<clipboard>"

    This functionality is provided via Pillow. Note that "<clipboard>" is
    only supported on Windows.

    Parameters for reading
    ----------------------
    No parameters.
    c                 C   r-   )Nz<clipboard>Fr.   r   r   r   r   r1   Z   r2   zClipboardGrabFormat._can_readc                 C   s:   |   }|sJ | }|d u rtdt|}|i fS )Nz5There seems to be no image data on the clipboard now.)r   grabclipboardRuntimeErrorr4   r5   r6   r   r   r   r#   _   s   
zClipboardGrabFormat._get_dataNr9   r   r   r   r   r;   N   r:   r;   )	r)   r   numpyr4   corer   r   r,   r;   r   r   r   r   <module>   s    '