
    
3j                    ~    S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	J
r
Jr  \(       a  S SKJr  S SKJr   " S S5      rg	)
    )annotations)TYPE_CHECKING)ScreenShotError)MonitorPixelPixelsPosSize)Iterator)Anyc                      \ rS rSrSr1 SkrSS.SS jjrSS jr\SS j5       r	\
SS	 j5       r\SS
 j5       r\SS j5       rSS jr\SS j5       r\SS j5       r\SS j5       r\SS j5       r\SS j5       rSrg)
ScreenShot   zScreenshot object.

.. note::

    A better name would have  been *Image*, but to prevent collisions
    with PIL.Image, it has been decided to use *ScreenShot*.
>   posrawsize__rgb__pixelsN)r   c                  S U l         S U l        Xl        [        US   US   5      U l        Uc  [        US   US   5      U l        g UU l        g )Nlefttopwidthheight)_ScreenShot__pixels_ScreenShot__rgbr   r	   r   r
   r   )selfdatamonitorr   s       H/home/wildlama/miniconda3/lib/python3.13/site-packages/mss/screenshot.py__init__ScreenShot.__init__   sV    '+#'
 # GFOWU^< HL|$ww/1BC	Y]	    c                    S[        U 5      R                   SU R                   SU R                   SU R                   SU R
                   S3$ )N<z pos=,z size=x>)type__name__r   r   r   r   r   s    r   __repr__ScreenShot.__repr__)   sJ    4:&&'uTYYKq
&TUVZVaVaUbbcddr"   c                R    SU R                   U R                  S4SU R                  S.$ )a7  NumPy array interface support.

This is used by NumPy, many SciPy projects, CuPy, PyTorch (via
``torch.from_numpy``), TensorFlow (via ``tf.convert_to_tensor``),
JAX (via ``jax.numpy.asarray``), Pandas, scikit-learn, Matplotlib,
some OpenCV functions, and others.  This allows you to pass a
:class:`ScreenShot` instance directly to these libraries without
needing to convert it first.

This is in HWC order, with 4 channels (BGRA).

.. seealso::

    https://numpy.org/doc/stable/reference/arrays.interface.html
       The NumPy array interface protocol specification
      z|u1)versionshapetypestrr   )r   r   r   r*   s    r   __array_interface__ScreenShot.__array_interface__,   s-    & kk4::q1HH	
 	
r"   c                   SSX#S.nU " X5      $ )z>Instantiate a new class given only screenshot's data and size.r   )r   r   r   r    )clsr   r   r   r   s        r   	from_sizeScreenShot.from_sizeE   s     QI4!!r"   c                ,    [        U R                  5      $ )a  BGRx values from the BGRx raw pixels.

The format is a bytes object with BGRxBGRx... sequence.  A specific
pixel can be accessed as
``bgra[(y * width + x) * 4:(y * width + x) * 4 + 4].``

.. note::
    While the name is ``bgra``, the alpha channel may or may not be
    valid.
)bytesr   r*   s    r   bgraScreenShot.bgraK   s     TXXr"   c                   U R                   (       dj  [        U R                  SSS2   U R                  SSS2   U R                  SSS2   5      n[        [        [	        U5      /U R
                  -  6 5      U l         U R                   $ )znRGB tuples.

The format is a list of rows.  Each row is a list of pixels.
Each pixel is a tuple of (R, G, B).
   Nr/      )r   zipr   listiterr   )r   
rgb_tupless     r   pixelsScreenShot.pixelsY   sp     }}*-dhhqt!tndhhqt!tndhhWZYZWZm*\J tJ'7&84::&E!FGDM}}r"   c                v     U R                   U   U   $ ! [         a  nSU SU S3n[        U5      UeSnAff = f)zTReturn the pixel value at a given position.

:returns: A tuple of (R, G, B) values.
zPixel location (z, z) is out of range.N)rE   
IndexErrorr   )r   coord_xcoord_yexcmsgs        r   pixelScreenShot.pixelf   sM    
	0;;w'00 	0$WIRy8JKC!#&C/	0s    
838c                   U R                   (       dk  [        U R                  U R                  -  S-  5      nU R                  nUSSS2   USSS2'   USSS2   USSS2'   USSS2   USSS2'   [        U5      U l         U R                   $ )zCompute RGB values from the BGRA raw pixels.

The format is a bytes object with BGRBGR... sequence.  A specific
pixel can be accessed as
``rgb[(y * width + x) * 3:(y * width + x) * 3 + 3]``.
r.   r?   Nr/   r@   )r   	bytearrayr   r   r   r;   )r   rgbr   s      r   rQ   ScreenShot.rgbq   s     zzDKK$**4q89C((C14a4yC!HADqD	C1ICaCC1IsDJzzr"   c                .    U R                   R                  $ )z(Convenient accessor to the top position.)r   r   r*   s    r   r   ScreenShot.top   s     xx||r"   c                .    U R                   R                  $ )z)Convenient accessor to the left position.)r   r   r*   s    r   r   ScreenShot.left   s     xx}}r"   c                .    U R                   R                  $ )z&Convenient accessor to the width size.)r   r   r*   s    r   r   ScreenShot.width   s     yyr"   c                .    U R                   R                  $ )z'Convenient accessor to the height size.)r   r   r*   s    r   r   ScreenShot.height   s     yyr"   )r   r   r   r   r   )r   rP   r   r   r   zSize | NonereturnNone)r[   str)r[   zdict[str, Any])
r7   ztype[ScreenShot]r   rP   r   intr   r^   r[   r   )r[   r;   )r[   r   )rI   r^   rJ   r^   r[   r   )r[   r^   )r)   
__module____qualname____firstlineno____doc__	__slots__r    r+   propertyr3   classmethodr8   r<   rE   rM   rQ   r   r   r   r   __static_attributes__r6   r"   r   r   r      s     <ITX ^e 
 
0 " "
   
 
	0  "          r"   r   N)
__future__r   typingr   mss.exceptionr   
mss.modelsr   r   r   r	   r
   collections.abcr   r   r   r6   r"   r   <module>rl      s+    #   ) 8 8(E  E r"   