%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/pdfgen/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/pdfgen/__pycache__/pdfimages.cpython-312.pyc

�

��d� ����dZdZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZmZdd	l
mZGd
�d�Zedk(r�ej"j%ej"j'ej(�d
d�Zej"j-e�sJd��de_eedd�Zej2�Zedej8�eej;e��yy)z3.3.0z@
Image functionality sliced out of canvas.py for generalization
�N)�	rl_config)�pdfutils)�pdfdoc)�isStr)�fp_str�asciiBase85Encode)�aspectRatioFixc�P�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d
d	�Z
		dd
�Zd�Zy)�PDFImagez�Wrapper around different "image sources".  You can make images
    from a PIL Image object, a filename (in which case it uses PIL),
    an image we previously cached (optimisation, hardly used these
    days) or a JPEG (which PDF supports natively).Nc��||_||_||_||_||_d|_||_d|_d|_g|_	d|_
|j�y)N�	DeviceRGB�)�image�x�y�width�height�filename�imageCaching�
colorSpace�bitsPerComponent�filters�source�getImageData)�selfrrrrr�cachings       �</usr/lib/python3/dist-packages/reportlab/pdfgen/pdfimages.py�__init__zPDFImage.__init__s_����
���������
������
�#���&��� !�������������c��t|jd�}	|j|�}|j�|S#|j�wxYw)N�rb)�openr�_jpg_imagedata�close)r�fp�results   r�
jpg_imagedatazPDFImage.jpg_imagedata*sD���$�*�*�d�
#��	��(�(��,�F��H�H�J��
��
�H�H�J�s	�;�A
c��tj|�}d|_|d|d}}|ddk(rd}n
|ddk(rd}nd}|jd�g}|j	d	|||t
jxrd
xsdfz�|j�}t
jrt|�}tj||�|j	d�|||fS)
N�JPEGr���
DeviceGray�r
�
DeviceCMYKz,BI /W %d /H %d /BPC 8 /CS /%s /F [%s/DCT] ID�/A85 ��EI)
r�readJPEGInfor�seek�appendr�useA85�readr�_chunker)r�	imageFile�info�imgwidth�	imgheightr�	imagedata�datas        rr#zPDFImage._jpg_imagedata4s����$�$�Y�/�����"�1�g�t�A�w�)����7�a�<�%�J�
�!�W��\�$�J�%�J����q���	����G�8�U^�`j�lu�l|�l|�mI�BI�mO�MO�KP�P�	Q��~�~������$�T�*�D����$�y�)�������8�Y�/�/rc�b�|j}tj|�stj|�tj
j
|�dtjxrdxsdz}t|d�j�}tttj|��}|S)Nrz.a85z.binr!)rr�cachedImageExists�cacheImageFile�os�path�splitextrr5r"�	readlines�list�map�str�strip)rr�
cachednamer<s    r�cache_imagedatazPDFImage.cache_imagedataJs����
�
���)�)�%�0��#�#�E�*��W�W�%�%�e�,�Q�/�9�3C�3C�3N��3X�RX�Y�
���D�)�3�3�5�	���S�Y�Y�	�2�3�	��rc��ddl}|j}|jdk(r.|j}|j	d�|j|�Sd|_d}|jdk(r|}d}d}nC|jdk(r	|}d	}d
}d
}n+|jdk(r|}d	}d
}n|jd�}d}d
}|j\}}	d||	||tjxrdxsdfzg}
t|d�r|jn|j�}||z|zdzd
z	}t|�||	zk(sJd��|j!|�}
tjrt#|
�}
t%j&|
|
�|
j)d�|
||	fS)Nrr)�PILr�CMYKr.��1r,r*�L�RGBr-z,BI /W %d /H %d /BPC %d /CS /%s /F [%s/Fl] IDr/r0�tobytes�zWrong amount of data for imager1)�zlibr�formatr%r3r#r�mode�convert�sizerr5�hasattrrR�tostring�len�compressrrr7r4)rrTrr%�bpc�myimager�bppr:r;r<�raw�	rowstrider=s              r�
PIL_imagedatazPDFImage.PIL_imagedataVs�����
�
���<�<����x�x�B��G�G�A�J��&�&�r�*�*�������:�:����G�%�J��C�
�Z�Z�3�
��G�%�J��C��C�
�Z�Z�3�
��G�%�J��C��m�m�E�*�G��J��C�%�l�l���)�B�X�y�Z]�_i�kt�k{�k{�lH�AH�lN�LN�EO�O�P�	�S�'�'�)�"<�w���'�BR�BR�U���c�\�#�%�a�'�!�+�	��3�x�9�Y�.�.�P�0P�P�.��}�}�S�!�����$�T�*�D����$�y�)�������8�Y�/�/rc���|jstj|d��}n|j�}|dj	�}t|d�}t|d�}|||fS)Nr*)�returnInMemoryr-)rrr@rJ�split�int)rrr<�wordsr:r;s      r�non_jpg_imagedatazPDFImage.non_jpg_imagedata�sd��� � � �/�/��Q�G�I��,�,�.�I��!��"�"�$���u�Q�x�=����a��M�	��(�I�-�-rc��|j}t|�rW||_tjj|�ddvr	|j
�\}}}n*|j|�\}}}n|j�\}}}||_	||_
||_|jxs||_|jxs||_
y#|j|�\}}}Y�YxYw)z1Gets data, height, width - whatever type of imager*)z.jpgz.JPGz.jpegz.JPEGN)rrrrArBrCr'rhrb�	imageDatar:r;rr)r�preserveAspectRatiorr<r:r;s      rrzPDFImage.getImageData�s����
�
����<�!�D�M��w�w����&�q�)�-O�O�S�59�5G�5G�5I�2�I�x��26�1G�1G��1N�.�	�8�Y�-1�-?�-?�-A�*�I�x��"��� ��
�"����Z�Z�+�8��
��k�k�.�Y����S�59�5K�5K�E�5R�2�I�x��s�C�Cc���|j}|j}|dks|dkryt|||j|j|||j
|j|�	\}	}
|_|_}|js|
|z}
|jjdt|j��dt|j|	|
��d��|j}|j}|jD]}|jj|��|jjd�|r|j||	|
||�|r%|j�D]}
t�|
||
<�y)z�Draw an Image into the specified rectangle.  If width and
        height are omitted, they are calculated from the image size.
        Also allow file names as well as images.  This allows a
        caching mechanismg���ư>Fzq z 0 0 z cm�QT)rrr	rrr:r;�bottomup�_coder4rrj�drawBoundary�keys�vars)r�canvasrk�anchor�
anchorAtXY�showBoundary�extraReturnrrrr�scaled�line�ks              r�drawInlineImagezPDFImage.drawInlineImage�sO���
�
��������:����U�-;�<O�PV�W[�W]�W]�^b�^d�^d�ej�kq�rv�r�r�AE�AO�AO�PZ�.[�*��!�D�J�t�{�F����A�f�H��������t�z�z�0B�F�4�;�;�XY�[\�D]�^�_��
�
�������N�N�	&�D��L�L����%�	&������C� ������Q�q��v�>�� �%�%�'�
+��!%�����A��
+�rc�Z�tj�}d|d<d|d<|j|d<|j|d<d|d<tj|j
�|d	<d
j
|jdd�d
z}tj||�
�}|j|�S)ztAllow it to be used within pdfdoc framework.  This only
        defines how it is stored, not how it is drawn later.z/XObject�Typez/Image�Subtype�Width�Heightr�BitsPerComponent�
ColorSpace�
r-���)�
dictionary�content)
r�
PDFDictionaryrr�PDFNamer�joinrj�	PDFStreamrU)r�document�dictr��strms     rrUzPDFImage.format�s����#�#�%��!��V��"��Y���
�
��W�
�����X��#$��
� �#�^�^�D�O�O�<��\���)�)�D�N�N�1�R�0�1�D�8�����4��A���{�{�8�$�$r)NNr)F)F�swFFN)
�__name__�
__module__�__qualname__�__doc__rr'r#rJrbrhrr{rU�rrrrs?��6�
�"�0�,
�,0�\.�/�*Y^�59��4
%rr�__main__�testzpythonpowered.gifzimage not foundr*�dzsource=)�__version__r�rA�	reportlabr�reportlab.pdfbaserr�reportlab.lib.utilsr�reportlab.lib.rl_accelrr�reportlab.lib.boxstuffr	rr�rBr��dirname�__file__�srcfile�isfile�
LongFormat�img�PDFDocument�doc�printrrUr�rr�<module>r�s���
��	��
���&�$�%�<�1�w%�w%�r�Z���g�g�l�l������	� 2� 2�3��#��G�
�7�7�>�>�'�"�5�$5�5�"��F��
�7�C��
%�C�
�&�
�
�
�C�	�)�C�J�J��	�#�*�*�S�/��r

Zerion Mini Shell 1.0