
    Dh                     X    d dl Z d dl mZmZmZmZmZ  G d de j                        ZdgZy)    N)ffiglib_libvips_libErrorat_least_libvipsc                   D     e Zd ZdZ fdZed        Zd Zd Zd Z	 xZ
S )RegionzWrap a VipsRegion object.

    c                 ,    t         t        |   |       y )N)superr	   __init__)selfpointer	__class__s     p/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/pyvips/vregion.pyr   zRegion.__init__   s    fd$W-    c                     t        j                  | j                        }|t        j                  k(  rt        d      t        j                  |      S )zMake a region on an image.

        Returns:
            A new :class:`.Region`.

        Raises:
            :class:`.Error`

        zunable to make region)r   vips_region_newr   r   NULLr   pyvipsr	   )imager   s     r   newz
Region.new   s?     **5==9chh/00}}W%%r   c                 n    t        dd      st        d      t        j                  | j                        S )zWidth of pixels held by region.   libvips too old)r   r   r   vips_region_widthr   r   s    r   widthzRegion.width$   s-    1%)**))$,,77r   c                 n    t        dd      st        d      t        j                  | j                        S )z Height of pixels held by region.r   r   )r   r   r   vips_region_heightr   r   s    r   heightzRegion.height+   s-    1%)****4<<88r   c                 X   t        dd      st        d      t        j                  d      }t	        j
                  | j                  |||||      }|t        j                  k(  rt        d      t        j                  |t        j                        }t        j                  ||d         S )zFill a region with pixel data.

        Pixels are filled with data!

        Returns:
            Pixel data.

        Raises:
            :class:`.Error`

        r   r   zsize_t *zunable to fetch from regionr   )r   r   r   r   r   vips_region_fetchr   r   gcr   g_freebuffer)r   xywhpsizer   s          r   fetchzRegion.fetch2   s      1%)**
#,,T\\1aAuMchh566&&(//2zz'58,,r   )__name__
__module____qualname____doc__r   staticmethodr   r   r    r+   __classcell__)r   s   @r   r	   r	      s0    . & &"89-r   r	   )	r   r   r   r   r   r   
VipsObjectr	   __all__ r   r   <module>r5      s.     C CA-V A-H *r   