<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.8">
  <compounddef id="GdEscposImage_8php" kind="file">
    <compoundname>GdEscposImage.php</compoundname>
    <innerclass refid="classMike42_1_1Escpos_1_1GdEscposImage" prot="public">Mike42::Escpos::GdEscposImage</innerclass>
    <innernamespace refid="namespaceMike42_1_1Escpos">Mike42::Escpos</innernamespace>
    <innernamespace refid="namespaceMike42_1_1Escpos_1_1EscposImage">Mike42::Escpos::EscposImage</innernamespace>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="normal">&lt;?php</highlight></codeline>
<codeline lineno="13"><highlight class="keyword">namespace<sp/></highlight><highlight class="normal"><ref refid="namespaceMike42_1_1Escpos" kindref="compound">Mike42\Escpos</ref>;</highlight></codeline>
<codeline lineno="14"><highlight class="normal"></highlight></codeline>
<codeline lineno="15"><highlight class="normal">use<sp/><ref refid="namespaceMike42_1_1Escpos_1_1EscposImage" kindref="compound">Mike42\Escpos\EscposImage</ref>;</highlight></codeline>
<codeline lineno="16"><highlight class="normal">use<sp/><ref refid="namespaceException" kindref="compound">Exception</ref>;</highlight></codeline>
<codeline lineno="17"><highlight class="normal"></highlight></codeline>
<codeline lineno="21" refid="classMike42_1_1Escpos_1_1GdEscposImage" refkind="compound"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classMike42_1_1Escpos_1_1GdEscposImage" kindref="compound">GdEscposImage</ref><sp/></highlight><highlight class="keyword">extends</highlight><highlight class="normal"><sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage" kindref="compound">EscposImage</ref></highlight></codeline>
<codeline lineno="22"><highlight class="normal">{</highlight></codeline>
<codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">protected</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">function</highlight><highlight class="normal"><sp/><ref refid="classMike42_1_1Escpos_1_1GdEscposImage_1ab4e41800418102bfb28edcdbcc9c758f" kindref="member">loadImageData</ref>($filename<sp/>=<sp/>null)</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="32"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>($filename<sp/>===<sp/>null)<sp/>{</highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Set<sp/>to<sp/>blank<sp/>image<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="34"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>parent::loadImageData($filename);</highlight></codeline>
<codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="37"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$ext<sp/>=<sp/>pathinfo($filename,<sp/>PATHINFO_EXTENSION);</highlight></codeline>
<codeline lineno="38"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">switch</highlight><highlight class="normal"><sp/>($ext)<sp/>{</highlight></codeline>
<codeline lineno="39"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/></highlight><highlight class="stringliteral">&quot;png&quot;</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="40"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$im<sp/>=<sp/>@imagecreatefrompng($filename);</highlight></codeline>
<codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/></highlight><highlight class="stringliteral">&quot;jpg&quot;</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$im<sp/>=<sp/>@imagecreatefromjpeg($filename);</highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="45"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">case</highlight><highlight class="normal"><sp/></highlight><highlight class="stringliteral">&quot;gif&quot;</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$im<sp/>=<sp/>@imagecreatefromgif($filename);</highlight></codeline>
<codeline lineno="47"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">default</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="namespaceException" kindref="compound">Exception</ref>(</highlight><highlight class="stringliteral">&quot;Image<sp/>format<sp/>not<sp/>supported<sp/>in<sp/>GD&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$this<sp/>-&gt;<sp/><ref refid="classMike42_1_1Escpos_1_1GdEscposImage_1a6b0302b37af902ee91dab477060b4fb6" kindref="member">readImageFromGdResource</ref>($im);</highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">function</highlight><highlight class="normal"><sp/><ref refid="classMike42_1_1Escpos_1_1GdEscposImage_1a6b0302b37af902ee91dab477060b4fb6" kindref="member">readImageFromGdResource</ref>($im)</highlight></codeline>
<codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!is_resource($im))<sp/>{</highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="namespaceException" kindref="compound">Exception</ref>(</highlight><highlight class="stringliteral">&quot;Failed<sp/>to<sp/>load<sp/>image.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/>elseif<sp/>(!<ref refid="classMike42_1_1Escpos_1_1EscposImage_1a276149e93b80d9c8ca60cca73402c68b" kindref="member">EscposImage::isGdLoaded</ref>())<sp/>{</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="namespaceException" kindref="compound">Exception</ref>(__FUNCTION__<sp/>.<sp/></highlight><highlight class="stringliteral">&quot;<sp/>requires<sp/>&apos;gd&apos;<sp/>extension.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Make<sp/>a<sp/>string<sp/>of<sp/>1&apos;s<sp/>and<sp/>0&apos;s<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1abbd7d7d81db631a2a555be2906856489" kindref="member">$imgHeight</ref><sp/>=<sp/>imagesy($im);</highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a16c9f28626c3fe81aec151042a9e5e58" kindref="member">$imgWidth</ref><sp/>=<sp/>imagesx($im);</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$imgData<sp/>=<sp/>str_repeat(</highlight><highlight class="stringliteral">&quot;\0&quot;</highlight><highlight class="normal">,<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1abbd7d7d81db631a2a555be2906856489" kindref="member">$imgHeight</ref><sp/>*<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a16c9f28626c3fe81aec151042a9e5e58" kindref="member">$imgWidth</ref>);</highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>($y<sp/>=<sp/>0;<sp/>$y<sp/>&lt;<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1abbd7d7d81db631a2a555be2906856489" kindref="member">$imgHeight</ref>;<sp/>$y++)<sp/>{</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>($x<sp/>=<sp/>0;<sp/>$x<sp/>&lt;<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a16c9f28626c3fe81aec151042a9e5e58" kindref="member">$imgWidth</ref>;<sp/>$x++)<sp/>{</highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>Faster<sp/>to<sp/>average<sp/>channels,<sp/>blend<sp/>alpha<sp/>and<sp/>negate<sp/>the<sp/>image<sp/>here<sp/>than<sp/>via<sp/>filters<sp/>(tested!)<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$cols<sp/>=<sp/>imagecolorsforindex($im,<sp/>imagecolorat($im,<sp/>$x,<sp/>$y));</highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>1<sp/>for<sp/>white,<sp/>0<sp/>for<sp/>black,<sp/>ignoring<sp/>transparency</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$greyness<sp/>=<sp/>(int)(($cols[</highlight><highlight class="stringliteral">&apos;red&apos;</highlight><highlight class="normal">]<sp/>+<sp/>$cols[</highlight><highlight class="stringliteral">&apos;green&apos;</highlight><highlight class="normal">]<sp/>+<sp/>$cols[</highlight><highlight class="stringliteral">&apos;blue&apos;</highlight><highlight class="normal">])<sp/>/<sp/>3)<sp/>&gt;&gt;<sp/>7;</highlight></codeline>
<codeline lineno="77"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>1<sp/>for<sp/>black,<sp/>0<sp/>for<sp/>white,<sp/>taking<sp/>into<sp/>account<sp/>transparency</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$black<sp/>=<sp/>(1<sp/>-<sp/>$greyness)<sp/>&gt;&gt;<sp/>($cols[</highlight><highlight class="stringliteral">&apos;alpha&apos;</highlight><highlight class="normal">]<sp/>&gt;&gt;<sp/>6);</highlight></codeline>
<codeline lineno="79"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$imgData[$y<sp/>*<sp/>$imgWidth<sp/>+<sp/>$x]<sp/>=<sp/>$black;</highlight></codeline>
<codeline lineno="80"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="81"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="82"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$this<sp/>-&gt;<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a27ea4fc9d668db992c8222400f566307" kindref="member">setImgWidth</ref>($imgWidth);</highlight></codeline>
<codeline lineno="83"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$this<sp/>-&gt;<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a3ff7e9483ccc19429dfbd214cdde520b" kindref="member">setImgHeight</ref>($imgHeight);</highlight></codeline>
<codeline lineno="84"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>$this<sp/>-&gt;<sp/><ref refid="classMike42_1_1Escpos_1_1EscposImage_1a085b7aab6c7269700d80c8e163aaf365" kindref="member">setImgData</ref>($imgData);</highlight></codeline>
<codeline lineno="85"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="86"><highlight class="normal">}</highlight></codeline>
    </programlisting>
    <location file="C:/www/aplusnet/incahellas.com/public_html/lib/escpos-php-development/src/Mike42/Escpos/GdEscposImage.php"/>
  </compounddef>
</doxygen>
