
    ^j,              	       	   d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZmZmZmZmZ d dlmZmZmZmZmZmZmZ d dlm Z m!Z! d dl"m#Z$ d dl"m%Z& d dl'm(Z( d dl)m*Z* d d	l+m,Z, ej-        Z-eZ.d
Z/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?dZ@dZA G d de          ZB G d d e          ZC G d! d"e          ZD G d# d$e          ZE G d% d&e          ZF ee          ZG ee          ZHee-jI        _J        e
e
eee
ge-jI        _K        ee-jL        _J        e
e
ge-jL        _K        ee-jM        _J        e
e
ge-jM        _K        ee-jN        _J        eeee ee          e
ge-jN        _K        ee-jO        _J        e
e
ge-jO        _K        ee-jP        _J        e
e.eee
ge-jP        _K        ee-jQ        _J        ee
e
ge-jQ        _K        d'e-jR        _J        e
ge-jR        _K        ee-jS        _J        ee
ge-jS        _K        ee-jT        _J        e
ge-jT        _K        ee-jU        _J        e
eee
e
e
e
ge-jU        _K        ee-jV        _J        e,eege-jV        _K        ee-jW        _J        e
ege-jW        _K        ee-jX        _J        e
eGge-jX        _K        ee-jY        _J        e
ee
eGge-jY        _K        ee-jZ        _J        e
 ee.           ee.          ge-jZ        _K        ee-j[        _J        e
e
ge-j[        _K        ee-j\        _J        e
e
ge-j\        _K        ee-j]        _J        e
eee
ge-j]        _K        ee-j^        _J        e
eeHge-j^        _K        ee-j_        _J        e
ege-j_        _K        ee-j`        _J        e
e
eHge-j`        _K        ee-ja        _J        e
eHge-ja        _K        ee-jb        _J        e
e
ege-jb        _K        ee-jc        _J        e
e
ege-jc        _K        ee-jd        _J        e
eee
e
e
e
eGeGg	e-jd        _K        ee-je        _J        e
ge-je        _K        ee-jf        _J        e
e
ege-jf        _K        ee-jg        _J        e
ege-jg        _K        ee-jh        _J        e
ege-jh        _K        ee-ji        _J        e
ege-ji        _K        ee-jj        _J        e
ge-jj        _K        d'e-jk        _J         ee          ge-jk        _K        ee-jl        _J        e
e
e
ge-jl        _K         G d( d)e!          Zmd* Znd+ Zod, Zp ep             d'S )-    )POINTER	Structurec_bufferc_bytec_floatc_longc_shortc_uint32c_ulongc_void_pc_wchar	c_wchar_pcastcreate_string_buffermemmovewindll)BOOLBYTEINTUINTULONG)	AnimationAnimationFrame	ImageDatabyrefc_intc_uintsizeof)ImageDecodeExceptionImageDecoder)	_kernel32)_ole32)	pIUnknown)GMEM_MOVEABLE)LONG_PTRi i i i i i i i i	  i
 & i  i0 i@4 i             i Q  c                   *    e Zd ZdefdefdefdefgZdS )GdiplusStartupInputGdiplusVersionDebugEventCallbackSuppressBackgroundThreadSuppressExternalCodecsN)__name__
__module____qualname__r
   r   r   _fields_     V/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/image/codecs/gdiplus.pyr+   r+   8   s5        	8$	x(	#T*	!4(	HHHr5   r+   c                       e Zd ZdefdefgZdS )GdiplusStartupOutputNotificationHookProcNotificationUnhookProcN)r0   r1   r2   r   _fieldsr4   r5   r6   r8   r8   A   s%        	*	!8,GGGr5   r8   c            	       Z    e Zd Zdefdefdefdefd ee          fd ee          fgZdS )
BitmapDataWidthHeightStridePixelFormatScan0ReservedN)r0   r1   r2   r   r   r   r   r3   r4   r5   r6   r=   r=   H   sU        	&	6	5		''&//"	WWV__%HHHr5   r=   c                   *    e Zd ZdefdefdefdefgZdS )RectXYr>   r?   N)r0   r1   r2   r   r3   r4   r5   r6   rE   rE   S   s3        	e	e	%	5	HHHr5   rE   c                   *    e Zd ZdefdefdefdefgZdS )PropertyItemidlengthtypevalueN)r0   r1   r2   r   r   r	   r   r3   r4   r5   r6   rI   rI   \   s4        	v	7		(	HHHr5   rI   Nc                   H    e Zd Zd Zd Zd Zed             Zd Zd Z	d Z
dS )	GDIPlusDecoderc                 
    g dS )N)z.bmp.gifz.jpgz.jpegz.exifz.pngz.tifz.tiffr4   selfs    r6   get_file_extensionsz"GDIPlusDecoder.get_file_extensions   s    RRRRr5   c                     dgS )NrQ   r4   rR   s    r6   get_animation_file_extensionsz,GDIPlusDecoder.get_animation_file_extensions   s     xr5   c                 Z   |                                 }t          j        t          t	          |                    }t          j        |          }t          ||t	          |                     t          j        |           t                      | _	        t          j        |dt          | j	                             t                      }t                              | j	        t          |                    }|dk    r-| j	                                         t#          d|p|z            |S )NTr   zGDI+ cannot load %r)readkernel32GlobalAllocr$   len
GlobalLockr   GlobalUnlockr#   streamole32CreateStreamOnHGlobalr   r   gdiplusGdipCreateBitmapFromStreamReleaser   )rS   filenamefiledatahglobptrbitmapstatuss           r6   _load_bitmapzGDIPlusDecoder._load_bitmap   s    yy{{ $]CII>>!%((T3t99%%%e$$$  kk#E4t{1C1CDDD 33DKvOOQ;;K!!!&'<@PD'QRRRr5   c           	         t                      }t                      }t                              | t          |          t          |                     t	          |j                  }t	          |j                  }t                      }t                              | t          |                     |j        }d}|t          k    rd}nE|t          k    rn9|t          k    rn-|t          t          t          t          fv rt          }n	d}t          }t                      }d|_        d|_        ||_        ||_        t)                      }t                              | t          |          t,          |t          |                     t/          |j        |z            }t3          ||j        t7          |                     t                              | t          |                     t;          |||||j                   S )NBGRABGRr   )REALra   GdipGetImageDimensionr   intrM   r   GdipGetImagePixelFormatPixelFormat24bppRGBPixelFormat32bppRGBPixelFormat32bppARGBPixelFormat16bppARGB1555PixelFormat32bppPARGBPixelFormat64bppARGBPixelFormat64bppPARGBrE   rF   rG   r>   r?   r=   GdipBitmapLockBitsImageLockModeReadr   r@   r   rB   r[   GdipBitmapUnlockBitsr   )ri   widthheightpffmtrectbitmap_databuffers           r6   
_get_imagezGDIPlusDecoder._get_image   s    %%feEllE&MMJJJEK  V\"" WW''b		:::X $$$CC&&&''',.C(*?A A A%BBC$B vv
 ll""65;;8I2uU`OaOabbb &k&86&ABB)3v;;777 	$$VU;-?-?@@@Vk6H5HIIIr5   c                 l    t                               |           | j                                         d S N)ra   GdipDisposeImager^   rc   )rS   ri   s     r6   _delete_bitmapzGDIPlusDecoder._delete_bitmap   s0      (((r5   c                     |st          |d          }|                     ||          }|                     |          }|                     |           |S )Nrb)openrk   r   r   )rS   rd   re   ri   images        r6   decodezGDIPlusDecoder.decode  sX     	($''D""8T22''F###r5   c                    |st          |d          }|                     ||          }t                      }t                              |t          |                     |j        dk     r$|                     |           t          d          t          |j        z              }t          
                    |||j                   t                      }t                              ||t          |                     t          }t                      }t                              ||t          |                     t          |j                  }	t          |	t!          t"                              j        }
t                              |||j        |	           |
j        t+          t,                    z  }t          |
j        t!          t,          |z                      j        }g }t/          |j                  D ]i}t                              |||           |                     |          }||         }|dk    rd}|                    t7          ||dz                       j|                     |           t9          |          S )Nr   r'   zImage has no frame dimensions
   g      Y@)r   rk   r   ra    GdipImageGetFrameDimensionsCountr   rM   r   r   r   GdipImageGetFrameDimensionsListGdipImageGetFrameCountPropertyTagFrameDelayGdipGetPropertyItemSizer   r   r   rI   contentsGdipGetPropertyItemrK   r   r   rangeGdipImageSelectActiveFramer   appendr   r   )rS   rd   re   ri   dimension_count
dimensionsframe_countprop_id	prop_sizeprop_buffer	prop_itemn_delaysdelaysframesir   delays                    r6   decode_animationzGDIPlusDecoder.decode_animation
  s*    	($''D""8T22 ((009O9OPPP 1$$'''&'FGGG !6699
//
ODYZZZhh&&vz5;M;MNNN'HH	''y9I9IJJJy//gl&;&;<<E	##FGY_kRRR#vf~~5iowv/@'A'ABBK{()) 	= 	=A..vz1EEEOOF++E1IEzzMM.d
;;<<<<F###   r5   N)r0   r1   r2   rT   rV   rk   staticmethodr   r   r   r   r4   r5   r6   rO   rO      s        S S S  
  , ,J ,J \,J\  
  *! *! *! *! *!r5   rO   c                       t                      gS r   )rO   r4   r5   r6   get_decodersr   7  s    r5   c                      g S r   r4   r4   r5   r6   get_encodersr   ;  s    Ir5   c                      t                      } t                      }d|_        t                      }t                              t          |           t          |          t          |                     d S )Nr'   )r   r+   r,   r8   ra   GdiplusStartupr   )token
startup_instartup_outs      r6   initr   ?  s]    IIE$&&J !J&((K5<<z):):E+<N<NOOOOOr5   )qctypesr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   ctypes.wintypesr   r   r   r   r   pyglet.imager   r   r   r   r   r   r   pyglet.image.codecsr   r    pyglet.libs.win32r!   rY   r"   r_   pyglet.libs.win32.comr#   pyglet.libs.win32.constantsr$   pyglet.libs.win32.typesr%   ra   ro   PixelFormat1bppIndexedPixelFormat4bppIndexedPixelFormat8bppIndexedPixelFormat16bppGrayScalePixelFormat16bppRGB555PixelFormat16bppRGB565rv   rs   rt   ru   rw   PixelFormat48bppRGBrx   ry   PixelFormatMaxr{   ImageLockModeWriteImageLockModeUserInputBufr   r+   r8   r=   rE   rI   INT_PTRUINT_PTRrz   restypeargtypesr|   GdipCloneStringFormatGdipCreateBitmapFromScan0rb   GdipCreateFontGdipCreateFontFamilyFromNameGdipCreateMatrixGdipCreateSolidFillr   GdipDrawStringGdipGetFamilyName	GdipFlush GdipGetFontCollectionFamilyCountGdipGetFontCollectionFamilyListrp   GdipGetImageGraphicsContextrr   r   r   GdipGraphicsClearr   r   r   r   GdipMeasureStringGdipNewPrivateFontCollectionGdipPrivateAddMemoryFontGdipSetPageUnitGdipSetStringFormatFlagsGdipSetTextRenderingHint%GdipStringFormatGetGenericTypographicGdiplusShutdownr   rO   r   r   r   r4   r5   r6   <module>r      sd                                     $ 9 8 8 8 8 8 8 8 8 8 8 8 8 8 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ B B B B B B B B 3 3 3 3 3 3 - - - - - - + + + + + + 5 5 5 5 5 5 , , , , , ,
." " " # " " " " " # " # # $         )       9              9       9    '#,,74== &+  "'/4&Q  #',  $)18(<  %(-  %*2H)=  &,1 ! ).3UE5''RV--Ya-b ! *-2 " */7.B " +!&  #+T3x"H  /4 $ ,1:Hh0O $ -#'   %-J  !&+  #(-x'8  $#(   %-J  !!&  #+YxS[]e"f  $)  !&.	7%C  "!  &.  38 ( 05=w4G ( 127 ' /4<c8W3U ' 0(-  %*2GGDMM774==)Q  &.3 # +08(/C # ,*/  ',4h+?  (&+  #(0&&('K  $*/  ',4fh+G  ($)  !&.%6  ").  &+3Xx*H  '38 ( 05=x4H ( 127 ' /4<h3M ' 0-2 " */74.H " +$)  !&.	5(HV^`hjqsz%{  "/4 $ ,19
 $ -+0   (-5x,G   )"'  $,e#4   +0   (-5u,=   )+0   (-5u,=   )8= - 5:B - 6"&  $+GENN#3   !&  #+Xx"@  E! E! E! E! E!\ E! E! E!P    P P P r5   