Ë
    ”2Úi²*  ã                   ó€   — d dl mZ ddlmZmZ d„ Zd„ Zd„ Z G d„ de«      Zd	„ Z	d
„ Z
 G d„ de«      Z G d„ de«      Zy)é   )Ú
BiffRecordé    )ÚpackÚunpackc                 ó$   — | j                  |«      S ©N)Ú	col_width)ÚsheetÚcols     úB/var/www/html/acx/venv/lib/python3.12/site-packages/xlwt/Bitmap.pyÚ	_size_colr      s   € Ø�?‰?˜3ÓÐó    c                 ó$   — | j                  |«      S r   )Ú
row_height)r
   Úrows     r   Ú	_size_rowr      s   € Ø×Ñ˜CÓ Ð r   c                 óp  — |t        | |«      k\  r$|t        | |«      z  }|dz  }|t        | |«      k\  rŒ$|t        | |«      k\  r$|t        | |«      z  }|dz  }|t        | |«      k\  rŒ$|}|}||z   dz
  }||z   dz
  }|t        | |«      k\  r$|t        | |«      z  }|dz  }|t        | |«      k\  rŒ$|t        | |«      k\  r$|t        | |«      z  }|dz  }|t        | |«      k\  rŒ$t        | |«      dk(  s-t        | |«      dk(  st        | |«      dk(  st        | |«      dk(  ryt        t        |«      t        | |«      z  dz  «      }t        t        |«      t        | |«      z  dz  «      }t        t        |«      t        | |«      z  dz  «      }	t        t        |«      t        | |«      z  dz  «      }
||||||	||
fS )aú  Calculate the vertices that define the position of the image as required by
    the OBJ record.

             +------------+------------+
             |     A      |      B     |
       +-----+------------+------------+
       |     |(x1,y1)     |            |
       |  1  |(A1)._______|______      |
       |     |    |              |     |
       |     |    |              |     |
       +-----+----|    BITMAP    |-----+
       |     |    |              |     |
       |  2  |    |______________.     |
       |     |            |        (B2)|
       |     |            |     (x2,y2)|
       +---- +------------+------------+

    Example of a bitmap that covers some of the area from cell A1 to cell B2.

    Based on the width and height of the bitmap we need to calculate 8 vars:
        col_start, row_start, col_end, row_end, x1, y1, x2, y2.
    The width and height of the cells are also variable and have to be taken into
    account.
    The values of col_start and row_start are passed in from the calling
    function. The values of col_end and row_end are calculated by subtracting
    the width and height of the bitmap from the width and height of the
    underlying cells.
    The vertices are expressed as a percentage of the underlying cell width as
    follows (rhs values are in pixels):

           x1 = X / W *1024
           y1 = Y / H *256
           x2 = (X-1) / W *1024
           y2 = (Y-1) / H *256

           Where:  X is distance from the left side of the underlying cell
                   Y is distance from the top of the underlying cell
                   W is the width of the cell
                   H is the height of the cell

    Note: the SDK incorrectly states that the height should be expressed as a
    percentage of 1024.

    col_start  - Col containing upper left corner of object
    row_start  - Row containing top left corner of object
    x1  - Distance to left side of object
    y1  - Distance to top of object
    width  - Width of image frame
    height  - Height of image frame

    r   r   Ni   é   )r   r   ÚintÚfloat)r
   Ú	row_startÚ	col_startÚx1Úy1ÚwidthÚheightÚrow_endÚcol_endÚx2Úy2s              r   Ú_position_imager!      sê  € ðj ”	˜% Ó+Ò
+Ø
Œi˜˜yÓ)Ñ)ˆØ�Q‰ˆ	ð ”	˜% Ó+Ó
+ð ”	˜% Ó+Ò
+Ø
Œi˜˜yÓ)Ñ)ˆØ�Q‰ˆ	ð ”	˜% Ó+Ó
+ð €GØ€GØ�B‰J˜‰N€EØ�b‰[˜1‰_€Fà”I˜e WÓ-Ò-Ø”˜5 'Ó*Ñ*ˆØ�1‰ˆð ”I˜e WÓ-Ó-ð ”Y˜u gÓ.Ò.Ø”)˜E 7Ó+Ñ+ˆØ�1‰ˆð ”Y˜u gÓ.Ó.ô
 
�5˜)Ó	$¨Ò	)¬y¸ÀÓ/HÈAÒ/MÜ˜% Ó+¨qÒ0´iÀÀwÓ6OÐSTÒ6TØä	ŒU�2‹Yœ 5¨)Ó4Ñ4°tÑ;Ó	<€BÜ	ŒU�2‹Yœ 5¨)Ó4Ñ4°sÑ:Ó	;€Bä	ŒU�5‹\œI e¨WÓ5Ñ5¸Ñ<Ó	=€Bä	ŒU�6‹]œY u¨gÓ6Ñ6¸Ñ<Ó	=€BØ�r˜9 b¨'°2°wÀÐCÐCr   c                   ó   — e Zd ZdZd„ Zy)ÚObjBmpRecordé]   c	           	      ó~  — |j                   |z  }	|j                  |z  }
t        ||||||	|
«      }|\  }}}}}}}}	 d}d}d}d}|}|}|}|}|}|}|}|}d} d}!d}"d}#d}$d}%d}&d}'d}(d})d}*d}+d},d}-d}.d}/d}0d}1t        d|«      }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d|«      z  }2|2t        d| «      z  }2|2t        d|!«      z  }2|2t        d|"«      z  }2|2t        d	|#«      z  }2|2t        d	|$«      z  }2|2t        d	|%«      z  }2|2t        d	|&«      z  }2|2t        d	|'«      z  }2|2t        d	|(«      z  }2|2t        d	|)«      z  }2|2t        d	|*«      z  }2|2t        d|+«      z  }2|2t        d|,«      z  }2|2t        d|-«      z  }2|2t        d|.«      z  }2|2t        d|/«      z  }2|2t        d|0«      z  }2|2t        d|1«      z  }2|2| _        y )
Nr   é   i  r   é	   éÿ   ú<Lz<Hz<B)r   r   r!   r   Ú	_rec_data)3Úselfr   r   r
   Úim_data_bmpÚxÚyÚscale_xÚscale_yr   r   Úcoordinatesr   r   r   r   r   r   r   r    ÚcObjÚOTÚidÚgrbitÚcolLÚdxLÚrwTÚdyTÚcolRÚdxRÚrwBÚdyBÚcbMacroÚ	Reserved1Ú	Reserved2ÚicvBackÚicvForeÚflsÚfAutoÚicvÚlnsÚlnwÚfAutoBÚfrsÚcfÚ	Reserved3Ú
cbPictFmlaÚ	Reserved4Úgrbit2Ú	Reserved5Údatas3                                                      r   Ú__init__zObjBmpRecord.__init__n   sß  € à×!Ñ! GÑ+ˆØ×#Ñ# gÑ-ˆô & e¨S°#°q¸!¸UÀFÓKˆàALÑ>ˆ	�2�y " g¨r°7¸Bð	ð ˆØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆ	Øˆ	ØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆØˆ	Øˆ
Øˆ	ØˆØˆ	ä�D˜$ÓˆØ”�T˜2“ÑˆØ”�T˜2“ÑˆØ”�T˜5Ó!Ñ!ˆØ”�T˜4Ó Ñ ˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜4Ó Ñ ˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜7Ó#Ñ#ˆØ”�T˜9Ó%Ñ%ˆØ”�T˜9Ó%Ñ%ˆØ”�T˜7Ó#Ñ#ˆØ”�T˜7Ó#Ñ#ˆØ”�T˜3“ÑˆØ”�T˜5Ó!Ñ!ˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜3“ÑˆØ”�T˜6Ó"Ñ"ˆØ”�T˜3“ÑˆØ”�T˜2“ÑˆØ”�T˜9Ó%Ñ%ˆØ”�T˜:Ó&Ñ&ˆØ”�T˜9Ó%Ñ%ˆØ”�T˜6Ó"Ñ"ˆØ”�T˜9Ó%Ñ%ˆàˆ�r   N)Ú__name__Ú
__module__Ú__qualname__Ú_REC_IDrQ   © r   r   r#   r#   k   s   „ Ø€GóLr   r#   c                 óŽ   — t        | d«      5 }|j                  «       }ddd«       t        |«      S # 1 sw Y   t        «      S xY w)z±Convert a 24 bit bitmap into the modified internal format used by Windows.
    This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the
    MSDN library.

    ÚrbN)ÚopenÚreadÚ_process_bitmap_data)ÚbitmapÚfhrP   s      r   Ú_process_bitmapr^   ¼   sE   € ô 
ˆf�dÓ	ð ˜rà�w‰w‹yˆ÷ô   Ó%Ð%÷ô   Ó%Ð%ús	   �1±Ac                 ó  — t        | «      dk  rt        d«      ‚| d d dk7  rt        d«      ‚| dd  } t        d| d d «      d   }|dz  }|d	z  }| dd  } | d	d  } t        d
| d d «      \  }}| dd  } |dkD  rt        d«      ‚|dkD  rt        d«      ‚t        d| d d «      \  }}| dd  } |dk7  rt        d«      ‚|dk7  rt        d«      ‚t        d| d d «      d   }| dd  } |dk7  rt        d«      ‚| dd  } t        dd	||dd«      }|| z   } |||| fS )Né6   z#bitmap doesn't contain enough data.é   s   BMz4bitmap doesn't appear to to be a valid bitmap image.r)   é   r   é   z<LLr&   iÿÿ  z-bitmap: largest image width supported is 65k.z.bitmap: largest image height supported is 65k.z<HHé   z'bitmap isn't a 24bit true color bitmap.r   z/bitmap: only 1 plane supported in bitmap image.z2bitmap: compression not supported in bitmap image.é   z<LHHHH)ÚlenÚ	Exceptionr   r   )rP   Úsizer   r   ÚplanesÚbitcountÚcompressionÚheaders           r   r[   r[   È   s|  € ä
ˆ4ƒy�DÒÜÐ=Ó>Ð>àˆRˆaˆ�EÒÜÐNÓOÐOà��ˆ8€Dô �$˜˜R˜a˜Ó! !Ñ$€DØˆT�M€DØˆT�M€DØ��ˆ8€Dà��ˆ9€Dä˜5 $ r¨ (Ó+�M€Eˆ6Ø��ˆ8€DØ�ŠÜÐGÓHÐHØ�ŠÜÐHÓIÐIä˜e T¨"¨1 XÓ.Ñ€FˆHØ��ˆ8€DØ�BŠÜÐAÓBÐBØ�!ŠÜÐIÓJÐJä˜˜t B Q˜xÓ(¨Ñ+€KØ��ˆ8€DØ�qÒÜÐLÓMÐMà��ˆ9€Dä�(˜F E¨6°4¸Ó>€FØ�D‰=€DØ�6˜4 Ð&Ð&r   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚImRawDataBmpRecordé   c                 óŽ   — t        j                  | «       t        |«      \  | _        | _        | _        }| j                  |«       y©z¡Insert a 24bit bitmap image in a worksheet. The main record required is
        IMDATA but it must be proceeded by a OBJ record to define its position.

        N)r   rQ   r[   r   r   rh   Ú_write_imdata)r+   rP   s     r   rQ   zImRawDataBmpRecord.__init__ø   s9   € ô
 	×Ñ˜DÔ!ä3GÈÓ3MÑ0ˆŒ
�D”K ¤¨DØ×Ñ˜4Õ r   c                 óP   — d}d}| j                   }t        d|||«      |z   | _        y )Nr'   r   z<HHL)rh   r   r*   )r+   rP   rJ   ÚenvÚlcbs        r   rr   z ImRawDataBmpRecord._write_imdata  s,   € àˆØˆØ�i‰iˆÜ˜f b¨#¨sÓ3°dÑ:ˆ�r   N)rR   rS   rT   rU   rQ   rr   rV   r   r   rn   rn   õ   s   „ Ø€Gò!ó;r   rn   c                   ó   — e Zd Zd„ Zy)ÚImDataBmpRecordc                 óŽ   — t        j                  | «       t        |«      \  | _        | _        | _        }| j                  |«       yrq   )r   rQ   r^   r   r   rh   rr   )r+   ÚfilenamerP   s      r   rQ   zImDataBmpRecord.__init__
  s9   € ô
 	×Ñ˜DÔ!ä3BÀ8Ó3LÑ0ˆŒ
�D”K ¤¨DØ×Ñ˜4Õ r   N)rR   rS   rT   rQ   rV   r   r   rw   rw   	  s   „ ó!r   rw   N)ÚBIFFRecordsr   Ústructr   r   r   r   r!   r#   r^   r[   rn   rw   rV   r   r   ú<module>r|      sR   ðõ $ß ò ò!òUDôpO�:ô Oòb
&ò*'ôZ;˜ô ;ô(	!Ð(õ 	!r   