
    
3j5                        S SK Jr  S SKrS SKrS SKrS SKJr  \(       a  S SKJr  Sr	S r
SrS rSr/ SQrS	r/ S
QrSrSrSr\" SS	5      rSS jrSSS.SS jjrg)    )annotationsN)TYPE_CHECKING)Path      i  )H   Z   l      )r                     c           
       ^ [        U 5      [        :  a  0 $ U S[         n[        U5      S-  S:w  a  0 $ [        R                  " SU5      u
  nnnnnnnn	n
nUS:w  a  0 $ US-  U-  n[        US-	  S-  S	-   5      [        US
-	  S-  S	-   5      -   [        US-  S	-   5      -   nSU US 30nU[        :w  a  XnS'   U[        :X  a  U[        -   US'   OU[        :w  a  X~S'   U[        -   US'   [         H  nXU[        -    m[        U4S j[         5       5      (       a  M.  T[           [        :X  aD  T[            nUR#                  S5      u  n  nUR%                  S5      nUR'                  SSS9US'   M  T[           [(        :X  d  M  T[            nUR#                  S5      u  n  nUR%                  S5      nUR'                  SSS9US'   M     U$ )ag  Parse a monitor's EDID block.

Many fields are currently ignored, but may be added in the future.

If the EDID block cannot be parsed, this returns an empty dict.

The dict defines the following fields.  Any of these may be
missing, if the EDID block does not define them.

- id_legacy (str): The legacy monitor ID, used in a number of
  APIs.  This is simply f"{manufacturer}{product_code:04X}".
  Those subfields are not part of the returned dict, but are
  nominally described as:

  - manufacturer (str): A three-letter, all-uppercase code
    specifying the manufacturer's legacy PnP ID.  The registry is
    managed by UEFI forum.
  - product_code (int): A 16-bit product code.  This is typically
    displayed as four hex digits if rendered to a string.

- serial_number (str | int): Serial number of the monitor.  EDID
  block may provide this as an int, string, or both; the string
  version is preferred.
- manufacture_week (int): The week, 1-54, of manufacture.  This
  may not be populated, even if the year is.  (The way the weeks
  are numbered is up to the manufacturer.)
- manufacture_year (int): The year, 1990 or later, of manufacture.
- model_year (int): The year, 1990 or later, that the model was
  released.  This is used if the manufacturer doesn't want to
  update their EDID block each year; the manufacture_year field is
  more common.
- display_name (str): The monitor's model.  This is the preferred
  value for display.  If this field is not present, then id_legacy
  is a distant second.

Currently, the serial_number and name fields are always in ASCII.
This function doesn't currently try to implement the
internationalization extensions defined in the VESA LS-EXT
standard.  However, we may in the future.

We also don't currently inspect the extension blocks.  The name
and serial number can be in CTA-861 extension blocks; I'll need to
see how common that is.
N   r   z<8s2BHIBBBB106xBxs        
       @   r   	id_legacy04Xserial_number
model_yearmanufacture_weekmanufacture_yearc              3  4   >#    U  H  nTU   S :g  v   M     g7f)r   N ).0field_offsetdescrs     C/home/wildlama/miniconda3/lib/python3.13/site-packages/mss/tools.py	<genexpr>parse_edid.<locals>.<genexpr>|   s     R<QLu\"a'<Qs      
    asciireplace)errorsdisplay_name)len_EDID_BLOCK_LENsumstructunpackchr_EDID_SERIAL_NUMBER_NOT_SET$_EDID_MANUFACTURE_WEEK_YEAR_IS_MODEL_EDID_YEAR_BASE_EDID_MANUFACTURE_WEEK_UNKNOWN_EDID_DESCR_OFFSETS_EDID_DESCR_LENany_EDID_DESCR_ZERO_LOCS_EDID_DESCR_TAG_LOC_EDID_DESCR_TAG_SN_EDID_DESCR_STR_LOC	partitionrstripdecode_EDID_DESCR_TAG_NAME)	edid_datablock0headerid_manufacturer_msbid_manufacturer_lsbid_product_codeid_serial_numberr   r   _edid_version_edid_revision
_ext_countid_manufacturer_packedid_manufacturerrvdescr_offsetsn_namer"   s                      @r#   
parse_edidrR      s)   ^ 9~'	 '(F
6{SA	 	)62 44	0A58KK$*b0B67
&!+r1R7
8	9
%*b0
1	2  	((=> B 66.???+o=<==%5!"!1O!C ,l_&DER<QRRR
 $%);;*+B||G,HB14B"$))GI)"FB&'+??,-D0JD!Q;;t$D!%WY!GB~% ,( I       )leveloutputc                 [         R                  n[        R                  nUu  pgUS-  nU" SS5      n	SR	                  [        U5       V
s/ s H  oX
U-  X-  U-    -   PM     sn
5      nU" SSSSS	S
SSS5	      n/ SQnU" SXgSSSSS5      US'   U" SU" SR	                  USS 5      5      S-  5      US'   U" S[        US   5      5      US'   SS[        R                  " X5      S/nU" SU" SR	                  USS 5      5      S-  5      US'   U" S[        US   5      5      US'   / SQnU" SU" US   5      S-  5      US'   U" S[        US   5      5      US'   U(       d  USR	                  X-   U-   5      -   $ [        US5       nUR                  U5        UR                  SR	                  U5      5        UR                  SR	                  U5      5        UR                  SR	                  U5      5        UR                  5         [        R                  " UR                  5       5        SSS5        gs  sn
f ! , (       d  f       g= f)a  Dump data to a PNG file.  If `output` is `None`, create no file but return
the whole PNG data.

:param bytes data: RGBRGB...RGB data.
:param tuple size: The (width, height) pair.
:param int level: PNG compression level (see :py:func:`zlib.compress()` for details).
:param str output: Output file name.

.. versionadded:: 3.0.0

.. versionchanged:: 3.2.0
   Added the ``level`` keyword argument to control the PNG compression level.
r   z>Br   rS   z>8B   P   N   G      r      )rS   s   IHDRrS   rS   z>2I5Br   r   z>Ir   l    s   IDAT)rS   s   IENDrS   rS   wbN)r/   packzlibcrc32joinranger,   compressopenwriteflushosfsyncfileno)datasizerU   rV   r_   ra   widthheightline
png_filtery	scanlinesmagicihdridatiendfilehs                    r#   to_pngrx      s)    ;;DJJEME19DdAJQVW]Q^_Q^AtHqx$'GGQ^_`IRRRR8E $D7E1aAq9DG4sxxQq	23j@ADG4T!W&DG $--	93?D4sxxQq	23j@ADG4T!W&DG $D4tAw*45DG4T!W&DGsxxd 2333	fd	uECHHTN#CHHTN#CHHTN# 	
  
 E `0 
	 s   H6B&H;;
I	)rA   bytesreturndict)
rk   ry   rl   ztuple[int, int]rU   intrV   zPath | str | Nonerz   zbytes | None)
__future__r   rh   r/   r`   typingr   pathlibr   r-   r2   r3   r5   r4   r6   r7   r9   r:   r;   r@   slicer<   rR   rx   r   rS   r#   <module>r      s    # 	      '+ $!" ( $    Arl qh CDae 6 6rS   