a
    §ˆcg  ã                   @   s    d Z ddlZG dd„ deƒZdS )ú An image cache. é    Nc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú
ImageCacher   c                 C   s   || _ || _i | _dS )z Creates a new image cache. N)Ú_widthÚ_heightÚ_images)ÚselfÚwidthÚheight© r
   úX/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/pyface/wx/image_cache.pyÚ__init__   s    zImageCache.__init__c                 C   sB   | j  |¡}|du r>t |tj¡}|  |¡ | ¡ }|| j |< |S )z6 Returns the specified image (currently as a bitmap). N)r   ÚgetÚwxZImageZBITMAP_TYPE_ANYÚ_scaleZConvertToBitmap)r   ÚfilenameZbmpÚimager
   r
   r   Ú	get_image#   s    

zImageCache.get_imagec                 C   s0   |  ¡ | jks| ¡ | jkr,| | j| j¡ |S )z, Scales the specified image (if necessary). )ZGetWidthr   Z	GetHeightr   ZRescale)r   r   r
   r
   r   r   >   s    ÿþzImageCache._scaleN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r
   r
   r
   r   r      s   r   )r   r   Úobjectr   r
   r
   r
   r   Ú<module>   s   