健康一贴灵,专注医药行业管理信息化

Android打印机--TSC 标签打印(转)

原文:https://blog.csdn.net/johnWcheung/article/details/72123858

打印机按照连接方式分为USB打印机、蓝牙打印机、网络打印机、云打印机、内联打印机;按照打印纸张大小分为带切刀的80厨房打印机和58热敏票据打印机;按照打印结果分为小票打印机和标签打印机;关于小票打印,一般都是使用ESC/POS打印指令,可以参见Android打印机–小票打印格式及模板设置,本篇主要介绍使用TSC标签打印指令实现打印标签功能。

首先是将打印指令作一下封装

/**
 * TSC 标签打印指令
 * Created by john on 17-5-12.
 */

public class LabelCommand {
private static final String DEBUG_TAG = "LabelCommand";
Vector<Byte> Command = null;

<span class="token keyword">public</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Vector</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">(</span><span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">,</span> <span class="token keyword">int</span> gap<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Vector</span><span class="token punctuation">(</span><span class="token number">4096</span><span class="token punctuation">,</span> <span class="token number">1024</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addSize</span><span class="token punctuation">(</span>width<span class="token punctuation">,</span> height<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addGap</span><span class="token punctuation">(</span>gap<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">clrCommand</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">addStrToCommand</span><span class="token punctuation">(</span><span class="token class-name">String</span> str<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bs <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>str<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">try</span> <span class="token punctuation">{<!-- --></span>
            bs <span class="token operator">=</span> str<span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">"GB2312"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">UnsupportedEncodingException</span> var4<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            var4<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> bs<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>bs<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addGap</span><span class="token punctuation">(</span><span class="token keyword">int</span> gap<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"GAP "</span> <span class="token operator">+</span> gap <span class="token operator">+</span> <span class="token string">" mm,"</span> <span class="token operator">+</span> <span class="token number">0</span> <span class="token operator">+</span> <span class="token string">" mm"</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addSize</span><span class="token punctuation">(</span><span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SIZE "</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">" mm,"</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">" mm"</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCashdrwer</span><span class="token punctuation">(</span><span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>FOOT m<span class="token punctuation">,</span> <span class="token keyword">int</span> t1<span class="token punctuation">,</span> <span class="token keyword">int</span> t2<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"CASHDRAWER "</span> <span class="token operator">+</span> m<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> t1 <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> t2 <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addOffset</span><span class="token punctuation">(</span><span class="token keyword">int</span> offset<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"OFFSET "</span> <span class="token operator">+</span> offset <span class="token operator">+</span> <span class="token string">" mm"</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addSpeed</span><span class="token punctuation">(</span><span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>SPEED speed<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SPEED "</span> <span class="token operator">+</span> speed<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addDensity</span><span class="token punctuation">(</span><span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>DENSITY density<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"DENSITY "</span> <span class="token operator">+</span> density<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addDirection</span><span class="token punctuation">(</span><span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>DIRECTION direction<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>MIRROR mirror<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"DIRECTION "</span> <span class="token operator">+</span> direction<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token char">','</span> <span class="token operator">+</span> mirror<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addReference</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"REFERENCE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addShif</span><span class="token punctuation">(</span><span class="token keyword">int</span> shift<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SHIFT "</span> <span class="token operator">+</span> shift <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCls</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"CLS\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addFeed</span><span class="token punctuation">(</span><span class="token keyword">int</span> dot<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"FEED "</span> <span class="token operator">+</span> dot <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addBackFeed</span><span class="token punctuation">(</span><span class="token keyword">int</span> dot<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BACKFEED "</span> <span class="token operator">+</span> dot <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addFormFeed</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"FORMFEED\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addHome</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"HOME\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPrint</span><span class="token punctuation">(</span><span class="token keyword">int</span> m<span class="token punctuation">,</span> <span class="token keyword">int</span> n<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"PRINT "</span> <span class="token operator">+</span> m <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> n <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPrint</span><span class="token punctuation">(</span><span class="token keyword">int</span> m<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"PRINT "</span> <span class="token operator">+</span> m <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCodePage</span><span class="token punctuation">(</span><span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>CODEPAGE page<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"CODEPAGE "</span> <span class="token operator">+</span> page<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addSound</span><span class="token punctuation">(</span><span class="token keyword">int</span> level<span class="token punctuation">,</span> <span class="token keyword">int</span> interval<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SOUND "</span> <span class="token operator">+</span> level <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> interval <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addLimitFeed</span><span class="token punctuation">(</span><span class="token keyword">int</span> n<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"LIMITFEED "</span> <span class="token operator">+</span> n <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addSelfTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SELFTEST\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addBar</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BAR "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addText</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>FONTTYPE font<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>ROTATION rotation<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>FONTMUL <span class="token class-name">Xscal</span><span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>FONTMUL <span class="token class-name">Yscal</span><span class="token punctuation">,</span> <span class="token class-name">String</span> text<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"TEXT "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> font<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> rotation<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token class-name">Xscal</span><span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token class-name">Yscal</span><span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> text <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">add1DBarcode</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>BARCODETYPE type<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>READABEL readable<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>ROTATION rotation<span class="token punctuation">,</span> <span class="token class-name">String</span> content<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">byte</span> narrow <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
    <span class="token keyword">byte</span> width <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BARCODE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> type<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> readable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> rotation<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> narrow <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> content <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">add1DBarcode</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>BARCODETYPE type<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>READABEL readable<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>ROTATION rotation<span class="token punctuation">,</span> <span class="token keyword">int</span> narrow<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token class-name">String</span> content<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BARCODE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> type<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> readable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> rotation<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> narrow <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> content <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addBox</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token keyword">int</span> xend<span class="token punctuation">,</span> <span class="token keyword">int</span> yend<span class="token punctuation">,</span> <span class="token keyword">int</span> thickness<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BOX "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> xend <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> yend <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> thickness <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addBitmap</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>BITMAP_MODE mode<span class="token punctuation">,</span> <span class="token keyword">int</span> nWidth<span class="token punctuation">,</span> <span class="token class-name">Bitmap</span> b<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>b <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">int</span> width <span class="token operator">=</span> <span class="token punctuation">(</span>nWidth <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">*</span> <span class="token number">8</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> height <span class="token operator">=</span> b<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> width <span class="token operator">/</span> b<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Log</span><span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">"BMP"</span><span class="token punctuation">,</span> <span class="token string">"bmp.getWidth() "</span> <span class="token operator">+</span> b<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Bitmap</span> grayBitmap <span class="token operator">=</span> <span class="token class-name">LabelUtils</span><span class="token punctuation">.</span><span class="token function">toGrayscale</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Bitmap</span> rszBitmap <span class="token operator">=</span> <span class="token class-name">LabelUtils</span><span class="token punctuation">.</span><span class="token function">resizeImage</span><span class="token punctuation">(</span>grayBitmap<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src <span class="token operator">=</span> <span class="token class-name">LabelUtils</span><span class="token punctuation">.</span><span class="token function">bitmapToBWPix</span><span class="token punctuation">(</span>rszBitmap<span class="token punctuation">)</span><span class="token punctuation">;</span>
        height <span class="token operator">=</span> src<span class="token punctuation">.</span>length <span class="token operator">/</span> width<span class="token punctuation">;</span>
        width <span class="token operator">/=</span> <span class="token number">8</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BITMAP "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> mode<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> codecontent <span class="token operator">=</span> <span class="token class-name">LabelUtils</span><span class="token punctuation">.</span><span class="token function">pixToLabelCmd</span><span class="token punctuation">(</span>src<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> k <span class="token operator">&lt;</span> codecontent<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>k<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>codecontent<span class="token punctuation">[</span>k<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token class-name">Log</span><span class="token punctuation">.</span><span class="token function">d</span><span class="token punctuation">(</span><span class="token string">"LabelCommand"</span><span class="token punctuation">,</span> <span class="token string">"codecontent"</span> <span class="token operator">+</span> codecontent<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addErase</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token keyword">int</span> xwidth<span class="token punctuation">,</span> <span class="token keyword">int</span> yheight<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"ERASE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> xwidth <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> yheight <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addReverse</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token keyword">int</span> xwidth<span class="token punctuation">,</span> <span class="token keyword">int</span> yheight<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"REVERSE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> xwidth <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> yheight <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQRCode</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>EEC level<span class="token punctuation">,</span> <span class="token keyword">int</span> cellwidth<span class="token punctuation">,</span> <span class="token class-name">LabelCommand</span><span class="token punctuation">.</span>ROTATION rotation<span class="token punctuation">,</span> <span class="token class-name">String</span> data<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"QRCODE "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> level<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> cellwidth <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token char">'A'</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> rotation<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> data <span class="token operator">+</span> <span class="token string">"\""</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token class-name">Vector</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Byte</span><span class="token punctuation">&gt;</span></span> <span class="token function">getCommand</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">return</span> <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterType</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"~!T\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">27</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">33</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">63</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addResetPrinter</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">27</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">33</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name"><span class="token namespace">this<span class="token punctuation">.</span></span>Command</span><span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token number">82</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterLife</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"~!@\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterMemory</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"~!A\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"~!F\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addQueryPrinterCodePage</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"~!I\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPeel</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        str <span class="token operator">=</span> <span class="token string">"SET PEEL "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addTear</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET TEAR "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCutter</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET CUTTER "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCutterBatch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET CUTTER BATCH\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addCutterPieces</span><span class="token punctuation">(</span><span class="token keyword">short</span> number<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET CUTTER "</span> <span class="token operator">+</span> number <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addReprint</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET REPRINT "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPrintKey</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET PRINTKEY "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPrintKey</span><span class="token punctuation">(</span><span class="token keyword">int</span> m<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET PRINTKEY "</span> <span class="token operator">+</span> m <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addPartialCutter</span><span class="token punctuation">(</span><span class="token class-name">ENABLE</span> enable<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"SET PARTIAL_CUTTER "</span> <span class="token operator">+</span> enable<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">"\r\n"</span><span class="token punctuation">;</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>str<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">addUserCommand</span><span class="token punctuation">(</span><span class="token class-name">String</span> command<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">addStrToCommand</span><span class="token punctuation">(</span>command<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> BARCODETYPE <span class="token punctuation">{<!-- --></span>
    <span class="token function">CODE128</span><span class="token punctuation">(</span><span class="token string">"128"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODE128M</span><span class="token punctuation">(</span><span class="token string">"128M"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN128</span><span class="token punctuation">(</span><span class="token string">"EAN128"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ITF25</span><span class="token punctuation">(</span><span class="token string">"25"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ITF25C</span><span class="token punctuation">(</span><span class="token string">"25C"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODE39</span><span class="token punctuation">(</span><span class="token string">"39"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODE39C</span><span class="token punctuation">(</span><span class="token string">"39C"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODE39S</span><span class="token punctuation">(</span><span class="token string">"39S"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODE93</span><span class="token punctuation">(</span><span class="token string">"93"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN13</span><span class="token punctuation">(</span><span class="token string">"EAN13"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN13_2</span><span class="token punctuation">(</span><span class="token string">"EAN13+2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN13_5</span><span class="token punctuation">(</span><span class="token string">"EAN13+5"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN8</span><span class="token punctuation">(</span><span class="token string">"EAN8"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN8_2</span><span class="token punctuation">(</span><span class="token string">"EAN8+2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN8_5</span><span class="token punctuation">(</span><span class="token string">"EAN8+5"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CODABAR</span><span class="token punctuation">(</span><span class="token string">"CODA"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">POST</span><span class="token punctuation">(</span><span class="token string">"POST"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCA</span><span class="token punctuation">(</span><span class="token string">"UPCA"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCA_2</span><span class="token punctuation">(</span><span class="token string">"UPCA+2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCA_5</span><span class="token punctuation">(</span><span class="token string">"UPCA+5"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCE</span><span class="token punctuation">(</span><span class="token string">"UPCE13"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCE_2</span><span class="token punctuation">(</span><span class="token string">"UPCE13+2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">UPCE_5</span><span class="token punctuation">(</span><span class="token string">"UPCE13+5"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CPOST</span><span class="token punctuation">(</span><span class="token string">"CPOST"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MSI</span><span class="token punctuation">(</span><span class="token string">"MSI"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MSIC</span><span class="token punctuation">(</span><span class="token string">"MSIC"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PLESSEY</span><span class="token punctuation">(</span><span class="token string">"PLESSEY"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ITF14</span><span class="token punctuation">(</span><span class="token string">"ITF14"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EAN14</span><span class="token punctuation">(</span><span class="token string">"EAN14"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token class-name">String</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">BARCODETYPE</span><span class="token punctuation">(</span><span class="token class-name">String</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> BITMAP_MODE <span class="token punctuation">{<!-- --></span>
    <span class="token function">OVERWRITE</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">OR</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">XOR</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">BITMAP_MODE</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> CODEPAGE <span class="token punctuation">{<!-- --></span>
    <span class="token function">PC437</span><span class="token punctuation">(</span><span class="token number">437</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PC850</span><span class="token punctuation">(</span><span class="token number">850</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PC852</span><span class="token punctuation">(</span><span class="token number">852</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PC860</span><span class="token punctuation">(</span><span class="token number">860</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PC863</span><span class="token punctuation">(</span><span class="token number">863</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PC865</span><span class="token punctuation">(</span><span class="token number">865</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">WPC1250</span><span class="token punctuation">(</span><span class="token number">1250</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">WPC1252</span><span class="token punctuation">(</span><span class="token number">1252</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">WPC1253</span><span class="token punctuation">(</span><span class="token number">1253</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">WPC1254</span><span class="token punctuation">(</span><span class="token number">1254</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">CODEPAGE</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> DENSITY <span class="token punctuation">{<!-- --></span>
    <span class="token function">DNESITY0</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY1</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY2</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY3</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY4</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY5</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY6</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY7</span><span class="token punctuation">(</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY8</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY9</span><span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY10</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY11</span><span class="token punctuation">(</span><span class="token number">11</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY12</span><span class="token punctuation">(</span><span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY13</span><span class="token punctuation">(</span><span class="token number">13</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY14</span><span class="token punctuation">(</span><span class="token number">14</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">DNESITY15</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">DENSITY</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> DIRECTION <span class="token punctuation">{<!-- --></span>
    <span class="token function">FORWARD</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">BACKWARD</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">DIRECTION</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> EEC <span class="token punctuation">{<!-- --></span>
    <span class="token function">LEVEL_L</span><span class="token punctuation">(</span><span class="token string">"L"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">LEVEL_M</span><span class="token punctuation">(</span><span class="token string">"M"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">LEVEL_Q</span><span class="token punctuation">(</span><span class="token string">"Q"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">LEVEL_H</span><span class="token punctuation">(</span><span class="token string">"H"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token class-name">String</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">EEC</span><span class="token punctuation">(</span><span class="token class-name">String</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> FONTMUL <span class="token punctuation">{<!-- --></span>
    <span class="token function">MUL_1</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_2</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_3</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_4</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_5</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_6</span><span class="token punctuation">(</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_7</span><span class="token punctuation">(</span><span class="token number">7</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_8</span><span class="token punctuation">(</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_9</span><span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MUL_10</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">FONTMUL</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> FONTTYPE <span class="token punctuation">{<!-- --></span>
    <span class="token function">FONT_1</span><span class="token punctuation">(</span><span class="token string">"1"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_2</span><span class="token punctuation">(</span><span class="token string">"2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_3</span><span class="token punctuation">(</span><span class="token string">"3"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_4</span><span class="token punctuation">(</span><span class="token string">"4"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_5</span><span class="token punctuation">(</span><span class="token string">"5"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_6</span><span class="token punctuation">(</span><span class="token string">"6"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_7</span><span class="token punctuation">(</span><span class="token string">"7"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FONT_8</span><span class="token punctuation">(</span><span class="token string">"8"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">SIMPLIFIED_CHINESE</span><span class="token punctuation">(</span><span class="token string">"TSS24.BF2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">TRADITIONAL_CHINESE</span><span class="token punctuation">(</span><span class="token string">"TST24.BF2"</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">KOREAN</span><span class="token punctuation">(</span><span class="token string">"K"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token class-name">String</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">FONTTYPE</span><span class="token punctuation">(</span><span class="token class-name">String</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> FOOT <span class="token punctuation">{<!-- --></span>
    <span class="token function">F2</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">F5</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">FOOT</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> MIRROR <span class="token punctuation">{<!-- --></span>
    <span class="token function">NORMAL</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">MIRROR</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">MIRROR</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> READABEL <span class="token punctuation">{<!-- --></span>
    <span class="token function">DISABLE</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">EANBEL</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">READABEL</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> ROTATION <span class="token punctuation">{<!-- --></span>
    <span class="token function">ROTATION_0</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ROTATION_90</span><span class="token punctuation">(</span><span class="token number">90</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ROTATION_180</span><span class="token punctuation">(</span><span class="token number">180</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ROTATION_270</span><span class="token punctuation">(</span><span class="token number">270</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">ROTATION</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> SPEED <span class="token punctuation">{<!-- --></span>
    <span class="token function">SPEED1DIV5</span><span class="token punctuation">(</span><span class="token number">1.5F</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">SPEED2</span><span class="token punctuation">(</span><span class="token number">2.0F</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">SPEED3</span><span class="token punctuation">(</span><span class="token number">3.0F</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">SPEED4</span><span class="token punctuation">(</span><span class="token number">4.0F</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">float</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">SPEED</span><span class="token punctuation">(</span><span class="token keyword">float</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">float</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604

然后定义一个操作这些指令的工具类

/**
 * 标签打印工具类
 * Created by john on 17-5-12.
 */

public class LabelUtils {
private static Pattern pattern = Pattern.compile("([a-zA-Z0-9!@#$^&*\(\)~\{\}:",\.<>/]+)");
private static int[] p0 = new int[]{0, 128};
private static int[] p1 = new int[]{0, 64};
private static int[] p2 = new int[]{0, 32};
private static int[] p3 = new int[]{0, 16};
private static int[] p4 = new int[]{0, 8};
private static int[] p5 = new int[]{0, 4};
private static int[] p6 = new int[]{0, 2};
private static int[][] Floyd16x16 = new int[][]{{0, 128, 32, 160, 8, 136, 40, 168, 2, 130, 34, 162, 10, 138, 42, 170}, {192, 64, 224, 96, 200, 72, 232, 104, 194, 66, 226, 98, 202, 74, 234, 106}, {48, 176, 16, 144, 56, 184, 24, 152, 50, 178, 18, 146, 58, 186, 26, 154}, {240, 112, 208, 80, 248, 120, 216, 88, 242, 114, 210, 82, 250, 122, 218, 90}, {12, 140, 44, 172, 4, 132, 36, 164, 14, 142, 46, 174, 6, 134, 38, 166}, {204, 76, 236, 108, 196, 68, 228, 100, 206, 78, 238, 110, 198, 70, 230, 102}, {60, 188, 28, 156, 52, 180, 20, 148, 62, 190, 30, 158, 54, 182, 22, 150}, {252, 124, 220, 92, 244, 116, 212, 84, 254, 126, 222, 94, 246, 118, 214, 86}, {3, 131, 35, 163, 11, 139, 43, 171, 1, 129, 33, 161, 9, 137, 41, 169}, {195, 67, 227, 99, 203, 75, 235, 107, 193, 65, 225, 97, 201, 73, 233, 105}, {51, 179, 19, 147, 59, 187, 27, 155, 49, 177, 17, 145, 57, 185, 25, 153}, {243, 115, 211, 83, 251, 123, 219, 91, 241, 113, 209, 81, 249, 121, 217, 89}, {15, 143, 47, 175, 7, 135, 39, 167, 13, 141, 45, 173, 5, 133, 37, 165}, {207, 79, 239, 111, 199, 71, 231, 103, 205, 77, 237, 109, 197, 69, 229, 101}, {63, 191, 31, 159, 55, 183, 23, 151, 61, 189, 29, 157, 53, 181, 21, 149}, {254, 127, 223, 95, 247, 119, 215, 87, 253, 125, 221, 93, 245, 117, 213, 85}};
private static int[][] Floyd8x8 = new int[][]{{0, 32, 8, 40, 2, 34, 10, 42}, {48, 16, 56, 24, 50, 18, 58, 26}, {12, 44, 4, 36, 14, 46, 6, 38}, {60, 28, 52, 20, 62, 30, 54, 22}, {3, 35, 11, 43, 1, 33, 9, 41}, {51, 19, 59, 27, 49, 17, 57, 25}, {15, 47, 7, 39, 13, 45, 5, 37}, {63, 31, 55, 23, 61, 29, 53, 21}};
public static final int PAPER_58_WIDTH = 32;
public static final int PAPER_80_WIDTH = 48;
private static int sPaperWidth = 48;
private static Integer[] theSet0 = new Integer[]{Integer.valueOf(1569), Integer.valueOf(1570), Integer.valueOf(1571), Integer.valueOf(1572), Integer.valueOf(1573), Integer.valueOf(1574), Integer.valueOf(1575), Integer.valueOf(1576), Integer.valueOf(1577), Integer.valueOf(1578), Integer.valueOf(1579), Integer.valueOf(1580), Integer.valueOf(1581), Integer.valueOf(1582), Integer.valueOf(1583), Integer.valueOf(1584), Integer.valueOf(1585), Integer.valueOf(1586), Integer.valueOf(1587), Integer.valueOf(1588), Integer.valueOf(1589), Integer.valueOf(1590), Integer.valueOf(1591), Integer.valueOf(1592), Integer.valueOf(1593), Integer.valueOf(1594), Integer.valueOf(1601), Integer.valueOf(1602), Integer.valueOf(1603), Integer.valueOf(1604), Integer.valueOf(1605), Integer.valueOf(1606), Integer.valueOf(1607), Integer.valueOf(1608), Integer.valueOf(1609), Integer.valueOf(1610), Integer.valueOf(17442), Integer.valueOf(17443), Integer.valueOf(17445), Integer.valueOf(17447)};
private static Integer[][] FormatTable = new Integer[][]{{Integer.valueOf('ﺀ'), Integer.valueOf('ﺀ'), Integer.valueOf('ﺀ'), Integer.valueOf('ﺀ')}, {Integer.valueOf('ﺁ'), Integer.valueOf('ﺂ'), Integer.valueOf('ﺁ'), Integer.valueOf('ﺂ')}, {Integer.valueOf('ﺃ'), Integer.valueOf('ﺄ'), Integer.valueOf('ﺃ'), Integer.valueOf('ﺄ')}, {Integer.valueOf('ﺅ'), Integer.valueOf('ﺅ'), Integer.valueOf('ﺅ'), Integer.valueOf('ﺅ')}, {Integer.valueOf('ﹽ'), Integer.valueOf('ﹽ'), Integer.valueOf('ﹽ'), Integer.valueOf('ﹽ')}, {Integer.valueOf('ﺋ'), Integer.valueOf('ﺋ'), Integer.valueOf('ﺋ'), Integer.valueOf('ﺋ')}, {Integer.valueOf('ﺍ'), Integer.valueOf('ﺎ'), Integer.valueOf('ﺍ'), Integer.valueOf('ﺎ')}, {Integer.valueOf('ﺏ'), Integer.valueOf('ﺏ'), Integer.valueOf('ﺑ'), Integer.valueOf('ﺑ')}, {Integer.valueOf('ﺓ'), Integer.valueOf('ﺓ'), Integer.valueOf('ﺓ'), Integer.valueOf('ﺓ')}, {Integer.valueOf('ﺕ'), Integer.valueOf('ﺕ'), Integer.valueOf('ﺗ'), Integer.valueOf('ﺗ')}, {Integer.valueOf('ﺙ'), Integer.valueOf('ﺙ'), Integer.valueOf('ﺛ'), Integer.valueOf('ﺛ')}, {Integer.valueOf('ﺝ'), Integer.valueOf('ﺝ'), Integer.valueOf('ﺟ'), Integer.valueOf('ﺟ')}, {Integer.valueOf('ﺡ'), Integer.valueOf('ﺡ'), Integer.valueOf('ﺣ'), Integer.valueOf('ﺣ')}, {Integer.valueOf('ﺥ'), Integer.valueOf('ﺥ'), Integer.valueOf('ﺧ'), Integer.valueOf('ﺧ')}, {Integer.valueOf('ﺩ'), Integer.valueOf('ﺩ'), Integer.valueOf('ﺩ'), Integer.valueOf('ﺩ')}, {Integer.valueOf('ﺫ'), Integer.valueOf('ﺫ'), Integer.valueOf('ﺫ'), Integer.valueOf('ﺫ')}, {Integer.valueOf('ﺭ'), Integer.valueOf('ﺭ'), Integer.valueOf('ﺭ'), Integer.valueOf('ﺭ')}, {Integer.valueOf('ﺯ'), Integer.valueOf('ﺯ'), Integer.valueOf('ﺯ'), Integer.valueOf('ﺯ')}, {Integer.valueOf('ﺱ'), Integer.valueOf('ﺱ'), Integer.valueOf('ﺳ'), Integer.valueOf('ﺳ')}, {Integer.valueOf('ﺵ'), Integer.valueOf('ﺵ'), Integer.valueOf('ﺷ'), Integer.valueOf('ﺷ')}, {Integer.valueOf('ﺹ'), Integer.valueOf('ﺹ'), Integer.valueOf('ﺻ'), Integer.valueOf('ﺻ')}, {Integer.valueOf('ﺽ'), Integer.valueOf('ﺽ'), Integer.valueOf('ﺿ'), Integer.valueOf('ﺿ')}, {Integer.valueOf('ﻁ'), Integer.valueOf('ﻁ'), Integer.valueOf('ﻁ'), Integer.valueOf('ﻁ')}, {Integer.valueOf('ﻅ'), Integer.valueOf('ﻅ'), Integer.valueOf('ﻅ'), Integer.valueOf('ﻅ')}, {Integer.valueOf('ﻉ'), Integer.valueOf('ﻊ'), Integer.valueOf('ﻋ'), Integer.valueOf('ﻌ')}, {Integer.valueOf('ﻍ'), Integer.valueOf('ﻎ'), Integer.valueOf('ﻏ'), Integer.valueOf('ﻐ')}, {Integer.valueOf('ﻑ'), Integer.valueOf('ﻑ'), Integer.valueOf('ﻓ'), Integer.valueOf('ﻓ')}, {Integer.valueOf('ﻕ'), Integer.valueOf('ﻕ'), Integer.valueOf('ﻗ'), Integer.valueOf('ﻗ')}, {Integer.valueOf('ﻙ'), Integer.valueOf('ﻙ'), Integer.valueOf('ﻛ'), Integer.valueOf('ﻛ')}, {Integer.valueOf('ﻝ'), Integer.valueOf('ﻝ'), Integer.valueOf('ﻟ'), Integer.valueOf('ﻟ')}, {Integer.valueOf('ﻡ'), Integer.valueOf('ﻡ'), Integer.valueOf('ﻣ'), Integer.valueOf('ﻣ')}, {Integer.valueOf('ﻥ'), Integer.valueOf('ﻥ'), Integer.valueOf('ﻧ'), Integer.valueOf('ﻧ')}, {Integer.valueOf('ﻩ'), Integer.valueOf('ﻩ'), Integer.valueOf('ﻫ'), Integer.valueOf('ﻫ')}, {Integer.valueOf('ﻭ'), Integer.valueOf('ﻭ'), Integer.valueOf('ﻭ'), Integer.valueOf('ﻭ')}, {Integer.valueOf('ﻯ'), Integer.valueOf('ﻰ'), Integer.valueOf('ﻯ'), Integer.valueOf('ﻰ')}, {Integer.valueOf('ﻱ'), Integer.valueOf('ﻲ'), Integer.valueOf('ﻳ'), Integer.valueOf('ﻳ')}, {Integer.valueOf('ﻵ'), Integer.valueOf('ﻶ'), Integer.valueOf('ﻵ'), Integer.valueOf('ﻶ')}, {Integer.valueOf('ﻷ'), Integer.valueOf('ﻸ'), Integer.valueOf('ﻷ'), Integer.valueOf('ﻸ')}, {Integer.valueOf('ﻹ'), Integer.valueOf('ﻺ'), Integer.valueOf('ﻹ'), Integer.valueOf('ﻺ')}, {Integer.valueOf('ﻻ'), Integer.valueOf('ﻼ'), Integer.valueOf('ﻻ'), Integer.valueOf('ﻼ')}};
static Integer[] theSet1 = new Integer[]{Integer.valueOf(1574), Integer.valueOf(1576), Integer.valueOf(1578), Integer.valueOf(1579), Integer.valueOf(1580), Integer.valueOf(1581), Integer.valueOf(1582), Integer.valueOf(1587), Integer.valueOf(1588), Integer.valueOf(1589), Integer.valueOf(1590), Integer.valueOf(1591), Integer.valueOf(1592), Integer.valueOf(1593), Integer.valueOf(1594), Integer.valueOf(1600), Integer.valueOf(1601), Integer.valueOf(1602), Integer.valueOf(1603), Integer.valueOf(1604), Integer.valueOf(1605), Integer.valueOf(1606), Integer.valueOf(1607), Integer.valueOf(1610)};
static Integer[] theSet2 = new Integer[]{Integer.valueOf(1570), Integer.valueOf(1571), Integer.valueOf(1572), Integer.valueOf(1573), Integer.valueOf(1574), Integer.valueOf(1575), Integer.valueOf(1576), Integer.valueOf(1577), Integer.valueOf(1578), Integer.valueOf(1579), Integer.valueOf(1580), Integer.valueOf(1581), Integer.valueOf(1582), Integer.valueOf(1583), Integer.valueOf(1584), Integer.valueOf(1585), Integer.valueOf(1586), Integer.valueOf(1587), Integer.valueOf(1588), Integer.valueOf(1589), Integer.valueOf(1590), Integer.valueOf(1591), Integer.valueOf(1592), Integer.valueOf(1593), Integer.valueOf(1594), Integer.valueOf(1600), Integer.valueOf(1601), Integer.valueOf(1602), Integer.valueOf(1603), Integer.valueOf(1604), Integer.valueOf(1605), Integer.valueOf(1606), Integer.valueOf(1607), Integer.valueOf(1608), Integer.valueOf(1609), Integer.valueOf(1610)};
public static final int ALGORITHM_DITHER_16x16 = 16;
public static final int ALGORITHM_DITHER_8x8 = 8;
public static final int ALGORITHM_TEXTMODE = 2;
public static final int ALGORITHM_GRAYTEXTMODE = 1;
public static final int[][] COLOR_PALETTE = new int[][]{new int[3], {255, 255, 255}};
public static final int FLOYD_STEINBERG_DITHER = 1;
private static int method = 1;
public static final int ATKINSON_DITHER = 2;

<span class="token keyword">public</span> <span class="token class-name">LabelUtils</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Bitmap</span> <span class="token function">resizeImage</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> bitmap<span class="token punctuation">,</span> <span class="token keyword">int</span> w<span class="token punctuation">,</span> <span class="token keyword">int</span> h<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> width <span class="token operator">=</span> bitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> height <span class="token operator">=</span> bitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">float</span> scaleWidth <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>w <span class="token operator">/</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>width<span class="token punctuation">;</span>
    <span class="token keyword">float</span> scaleHeight <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>h <span class="token operator">/</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>height<span class="token punctuation">;</span>
    <span class="token class-name">Matrix</span> matrix <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Matrix</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    matrix<span class="token punctuation">.</span><span class="token function">postScale</span><span class="token punctuation">(</span>scaleWidth<span class="token punctuation">,</span> scaleHeight<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Bitmap</span> resizedBitmap <span class="token operator">=</span> <span class="token class-name">Bitmap</span><span class="token punctuation">.</span><span class="token function">createBitmap</span><span class="token punctuation">(</span>bitmap<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> matrix<span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> resizedBitmap<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">saveMyBitmap</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> mBitmap<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">File</span> f <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span><span class="token class-name">Environment</span><span class="token punctuation">.</span><span class="token function">getExternalStorageDirectory</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">"Btatotest.jpeg"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">try</span> <span class="token punctuation">{<!-- --></span>
        f<span class="token punctuation">.</span><span class="token function">createNewFile</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">IOException</span> var6<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token class-name">FileOutputStream</span> fOut <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

    <span class="token keyword">try</span> <span class="token punctuation">{<!-- --></span>
        fOut <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
        mBitmap<span class="token punctuation">.</span><span class="token function">compress</span><span class="token punctuation">(</span><span class="token class-name">CompressFormat</span><span class="token punctuation">.</span>PNG<span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">,</span> fOut<span class="token punctuation">)</span><span class="token punctuation">;</span>
        fOut<span class="token punctuation">.</span><span class="token function">flush</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        fOut<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">FileNotFoundException</span> var4<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">IOException</span> var5<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Bitmap</span> <span class="token function">toGrayscale</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> bmpOriginal<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> height <span class="token operator">=</span> bmpOriginal<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> width <span class="token operator">=</span> bmpOriginal<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Bitmap</span> bmpGrayscale <span class="token operator">=</span> <span class="token class-name">Bitmap</span><span class="token punctuation">.</span><span class="token function">createBitmap</span><span class="token punctuation">(</span>width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> <span class="token class-name">Config</span><span class="token punctuation">.</span>RGB_565<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Canvas</span> c <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Canvas</span><span class="token punctuation">(</span>bmpGrayscale<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Paint</span> paint <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Paint</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ColorMatrix</span> cm <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ColorMatrix</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    cm<span class="token punctuation">.</span><span class="token function">setSaturation</span><span class="token punctuation">(</span><span class="token number">0.0F</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ColorMatrixColorFilter</span> f <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ColorMatrixColorFilter</span><span class="token punctuation">(</span>cm<span class="token punctuation">)</span><span class="token punctuation">;</span>
    paint<span class="token punctuation">.</span><span class="token function">setColorFilter</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
    c<span class="token punctuation">.</span><span class="token function">drawBitmap</span><span class="token punctuation">(</span>bmpOriginal<span class="token punctuation">,</span> <span class="token number">0.0F</span><span class="token punctuation">,</span> <span class="token number">0.0F</span><span class="token punctuation">,</span> paint<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> bmpGrayscale<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">pixToEscRastBitImageCmd</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src<span class="token punctuation">,</span> <span class="token keyword">int</span> nWidth<span class="token punctuation">,</span> <span class="token keyword">int</span> nMode<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> nHeight <span class="token operator">=</span> src<span class="token punctuation">.</span>length <span class="token operator">/</span> nWidth<span class="token punctuation">;</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token number">8</span> <span class="token operator">+</span> src<span class="token punctuation">.</span>length <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">29</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">118</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">48</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>nMode <span class="token operator">&amp;</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>nWidth <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">%</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>nWidth <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">/</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">6</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>nHeight <span class="token operator">%</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">7</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>nHeight <span class="token operator">/</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">8</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> data<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        data<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>p0<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p1<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p2<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p3<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p4<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p5<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p6<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        k <span class="token operator">+=</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">pixToEscRastBitImageCmd</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>src<span class="token punctuation">.</span>length <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> data<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        data<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>p0<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p1<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p2<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p3<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p4<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p5<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p6<span class="token punctuation">[</span>src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> src<span class="token punctuation">[</span>k <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        k <span class="token operator">+=</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">pixToEscNvBitImageCmd</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>src<span class="token punctuation">.</span>length <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">+</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>width <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">%</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>width <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">/</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>height <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">%</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>height <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">/</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">boolean</span> k <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> width<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">int</span> var7 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> j <span class="token operator">&lt;</span> height <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">;</span> <span class="token operator">++</span>j<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            data<span class="token punctuation">[</span><span class="token number">4</span> <span class="token operator">+</span> j <span class="token operator">+</span> i <span class="token operator">*</span> height <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>p0<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p1<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">1</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p2<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">2</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p3<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">3</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p4<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">4</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p5<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">5</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p6<span class="token punctuation">[</span>src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">6</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> src<span class="token punctuation">[</span>i <span class="token operator">+</span> var7 <span class="token operator">+</span> <span class="token number">7</span> <span class="token operator">*</span> width<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            var7 <span class="token operator">+=</span> <span class="token number">8</span> <span class="token operator">*</span> width<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">pixToLabelCmd</span><span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>src<span class="token punctuation">.</span>length <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> k <span class="token operator">&lt;</span> data<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>k<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">byte</span> temp <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>p0<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p1<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p2<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p3<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p4<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p5<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p6<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token operator">~</span>temp<span class="token punctuation">)</span><span class="token punctuation">;</span>
        j <span class="token operator">+=</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">pixToTscCmd</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">,</span> <span class="token keyword">int</span> mode<span class="token punctuation">,</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> src<span class="token punctuation">,</span> <span class="token keyword">int</span> nWidth<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> height <span class="token operator">=</span> src<span class="token punctuation">.</span>length <span class="token operator">/</span> nWidth<span class="token punctuation">;</span>
    <span class="token keyword">int</span> width <span class="token operator">=</span> nWidth <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> str <span class="token operator">=</span> <span class="token string">"BITMAP "</span> <span class="token operator">+</span> x <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> y <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> width <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> height <span class="token operator">+</span> <span class="token string">","</span> <span class="token operator">+</span> mode <span class="token operator">+</span> <span class="token string">","</span><span class="token punctuation">;</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> bitmap <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

    <span class="token keyword">try</span> <span class="token punctuation">{<!-- --></span>
        bitmap <span class="token operator">=</span> str<span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">"GB2312"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">UnsupportedEncodingException</span> var13<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        var13<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> arrayOfByte <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>src<span class="token punctuation">.</span>length <span class="token operator">/</span> <span class="token number">8</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> data <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> data <span class="token operator">&lt;</span> arrayOfByte<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>data<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">byte</span> temp <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span>p0<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p1<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p2<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p3<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p4<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p5<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> p6<span class="token punctuation">[</span>src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">+</span> src<span class="token punctuation">[</span>j <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        arrayOfByte<span class="token punctuation">[</span>data<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token operator">~</span>temp<span class="token punctuation">)</span><span class="token punctuation">;</span>
        j <span class="token operator">+=</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> var14 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>bitmap<span class="token punctuation">.</span>length <span class="token operator">+</span> arrayOfByte<span class="token punctuation">.</span>length<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">arraycopy</span><span class="token punctuation">(</span>bitmap<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> var14<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">arraycopy</span><span class="token punctuation">(</span>arrayOfByte<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> var14<span class="token punctuation">,</span> bitmap<span class="token punctuation">.</span>length<span class="token punctuation">,</span> arrayOfByte<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> var14<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">format_K_dither16x16</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> orgpixels<span class="token punctuation">,</span> <span class="token keyword">int</span> xsize<span class="token punctuation">,</span> <span class="token keyword">int</span> ysize<span class="token punctuation">,</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> despixels<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> y <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> y <span class="token operator">&lt;</span> ysize<span class="token punctuation">;</span> <span class="token operator">++</span>y<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> x <span class="token operator">&lt;</span> xsize<span class="token punctuation">;</span> <span class="token operator">++</span>x<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>orgpixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token class-name">Floyd16x16</span><span class="token punctuation">[</span>x <span class="token operator">&amp;</span> <span class="token number">15</span><span class="token punctuation">]</span><span class="token punctuation">[</span>y <span class="token operator">&amp;</span> <span class="token number">15</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token operator">++</span>k<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">bitmapToBWPix</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> mBitmap<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> pixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span>mBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> mBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>mBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> mBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token class-name">Bitmap</span> grayBitmap <span class="token operator">=</span> <span class="token function">toGrayscale</span><span class="token punctuation">(</span>mBitmap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    grayBitmap<span class="token punctuation">.</span><span class="token function">getPixels</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> mBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> mBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> mBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">format_K_dither16x16</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> data<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">format_K_dither16x16_int</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> orgpixels<span class="token punctuation">,</span> <span class="token keyword">int</span> xsize<span class="token punctuation">,</span> <span class="token keyword">int</span> ysize<span class="token punctuation">,</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> despixels<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> y <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> y <span class="token operator">&lt;</span> ysize<span class="token punctuation">;</span> <span class="token operator">++</span>y<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> x <span class="token operator">&lt;</span> xsize<span class="token punctuation">;</span> <span class="token operator">++</span>x<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>orgpixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token class-name">Floyd16x16</span><span class="token punctuation">[</span>x <span class="token operator">&amp;</span> <span class="token number">15</span><span class="token punctuation">]</span><span class="token punctuation">[</span>y <span class="token operator">&amp;</span> <span class="token number">15</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">16777216</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token operator">++</span>k<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">format_K_dither8x8_int</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> orgpixels<span class="token punctuation">,</span> <span class="token keyword">int</span> xsize<span class="token punctuation">,</span> <span class="token keyword">int</span> ysize<span class="token punctuation">,</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> despixels<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> k <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> y <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> y <span class="token operator">&lt;</span> ysize<span class="token punctuation">;</span> <span class="token operator">++</span>y<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> x <span class="token operator">&lt;</span> xsize<span class="token punctuation">;</span> <span class="token operator">++</span>x<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span>orgpixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">)</span> <span class="token operator">&gt;&gt;</span> <span class="token number">2</span> <span class="token operator">&gt;</span> <span class="token class-name">Floyd8x8</span><span class="token punctuation">[</span>x <span class="token operator">&amp;</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">[</span>y <span class="token operator">&amp;</span> <span class="token number">7</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                despixels<span class="token punctuation">[</span>k<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">16777216</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token operator">++</span>k<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">bitmapToBWPix_int</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> mBitmap<span class="token punctuation">,</span> <span class="token keyword">int</span> algorithm<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> pixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token class-name">Bitmap</span> grayBitmap<span class="token punctuation">;</span>
    <span class="token keyword">switch</span><span class="token punctuation">(</span>algorithm<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">case</span> <span class="token number">2</span><span class="token operator">:</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token number">8</span><span class="token operator">:</span>
            grayBitmap <span class="token operator">=</span> <span class="token function">toGrayscale</span><span class="token punctuation">(</span>mBitmap<span class="token punctuation">)</span><span class="token punctuation">;</span>
            pixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span>grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            grayBitmap<span class="token punctuation">.</span><span class="token function">getPixels</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">format_K_dither8x8_int</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pixels<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token number">16</span><span class="token operator">:</span>
        <span class="token keyword">default</span><span class="token operator">:</span>
            grayBitmap <span class="token operator">=</span> <span class="token function">toGrayscale</span><span class="token punctuation">(</span>mBitmap<span class="token punctuation">)</span><span class="token punctuation">;</span>
            pixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span>grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            grayBitmap<span class="token punctuation">.</span><span class="token function">getPixels</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">format_K_dither16x16_int</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> grayBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> pixels<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> pixels<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Bitmap</span> <span class="token function">toBinaryImage</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> mBitmap<span class="token punctuation">,</span> <span class="token keyword">int</span> nWidth<span class="token punctuation">,</span> <span class="token keyword">int</span> algorithm<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> width <span class="token operator">=</span> <span class="token punctuation">(</span>nWidth <span class="token operator">+</span> <span class="token number">7</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">8</span> <span class="token operator">*</span> <span class="token number">8</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> height <span class="token operator">=</span> mBitmap<span class="token punctuation">.</span><span class="token function">getHeight</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> width <span class="token operator">/</span> mBitmap<span class="token punctuation">.</span><span class="token function">getWidth</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Bitmap</span> rszBitmap <span class="token operator">=</span> <span class="token function">resizeImage</span><span class="token punctuation">(</span>mBitmap<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> pixels <span class="token operator">=</span> <span class="token function">bitmapToBWPix_int</span><span class="token punctuation">(</span>rszBitmap<span class="token punctuation">,</span> algorithm<span class="token punctuation">)</span><span class="token punctuation">;</span>
    rszBitmap<span class="token punctuation">.</span><span class="token function">setPixels</span><span class="token punctuation">(</span>pixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> rszBitmap<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">getCloseColor</span><span class="token punctuation">(</span><span class="token keyword">int</span> tr<span class="token punctuation">,</span> <span class="token keyword">int</span> tg<span class="token punctuation">,</span> <span class="token keyword">int</span> tb<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> minDistanceSquared <span class="token operator">=</span> <span class="token number">195076</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> bestIndex <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> COLOR_PALETTE<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">int</span> rdiff <span class="token operator">=</span> tr <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> gdiff <span class="token operator">=</span> tg <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> bdiff <span class="token operator">=</span> tb <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> distanceSquared <span class="token operator">=</span> rdiff <span class="token operator">*</span> rdiff <span class="token operator">+</span> gdiff <span class="token operator">*</span> gdiff <span class="token operator">+</span> bdiff <span class="token operator">*</span> bdiff<span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>distanceSquared <span class="token operator">&lt;</span> minDistanceSquared<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            minDistanceSquared <span class="token operator">=</span> distanceSquared<span class="token punctuation">;</span>
            bestIndex <span class="token operator">=</span> i<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> bestIndex<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">setPixel</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> input<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">,</span> <span class="token keyword">int</span> col<span class="token punctuation">,</span> <span class="token keyword">int</span> row<span class="token punctuation">,</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> p<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>col <span class="token operator">&lt;</span> <span class="token number">0</span> <span class="token operator">||</span> col <span class="token operator">&gt;=</span> width<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        col <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>row <span class="token operator">&lt;</span> <span class="token number">0</span> <span class="token operator">||</span> row <span class="token operator">&gt;=</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        row <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">int</span> index <span class="token operator">=</span> row <span class="token operator">*</span> width <span class="token operator">+</span> col<span class="token punctuation">;</span>
    input<span class="token punctuation">[</span>index<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">16777216</span> <span class="token operator">|</span> <span class="token function">clamp</span><span class="token punctuation">(</span>p<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">&lt;&lt;</span> <span class="token number">16</span> <span class="token operator">|</span> <span class="token function">clamp</span><span class="token punctuation">(</span>p<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">&lt;&lt;</span> <span class="token number">8</span> <span class="token operator">|</span> <span class="token function">clamp</span><span class="token punctuation">(</span>p<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">getPixel</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> input<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">,</span> <span class="token keyword">int</span> col<span class="token punctuation">,</span> <span class="token keyword">int</span> row<span class="token punctuation">,</span> <span class="token keyword">float</span> error<span class="token punctuation">,</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> ergb<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>col <span class="token operator">&lt;</span> <span class="token number">0</span> <span class="token operator">||</span> col <span class="token operator">&gt;=</span> width<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        col <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span><span class="token punctuation">(</span>row <span class="token operator">&lt;</span> <span class="token number">0</span> <span class="token operator">||</span> row <span class="token operator">&gt;=</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        row <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">int</span> index <span class="token operator">=</span> row <span class="token operator">*</span> width <span class="token operator">+</span> col<span class="token punctuation">;</span>
    <span class="token keyword">int</span> tr <span class="token operator">=</span> input<span class="token punctuation">[</span>index<span class="token punctuation">]</span> <span class="token operator">&gt;&gt;</span> <span class="token number">16</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> tg <span class="token operator">=</span> input<span class="token punctuation">[</span>index<span class="token punctuation">]</span> <span class="token operator">&gt;&gt;</span> <span class="token number">8</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> tb <span class="token operator">=</span> input<span class="token punctuation">[</span>index<span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
    tr <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>tr <span class="token operator">+</span> error <span class="token operator">*</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>ergb<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    tg <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>tg <span class="token operator">+</span> error <span class="token operator">*</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>ergb<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    tb <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>tb <span class="token operator">+</span> error <span class="token operator">*</span> <span class="token punctuation">(</span><span class="token keyword">float</span><span class="token punctuation">)</span>ergb<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{<!-- --></span>tr<span class="token punctuation">,</span> tg<span class="token punctuation">,</span> tb<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token function">clamp</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">return</span> value <span class="token operator">&gt;</span> <span class="token number">255</span><span class="token operator">?</span><span class="token number">255</span><span class="token operator">:</span><span class="token punctuation">(</span>value <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token operator">?</span><span class="token number">0</span><span class="token operator">:</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Bitmap</span> <span class="token function">filter</span><span class="token punctuation">(</span><span class="token class-name">Bitmap</span> nbm<span class="token punctuation">,</span> <span class="token keyword">int</span> width<span class="token punctuation">,</span> <span class="token keyword">int</span> height<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> inPixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span>width <span class="token operator">*</span> height<span class="token punctuation">]</span><span class="token punctuation">;</span>
    nbm<span class="token punctuation">.</span><span class="token function">getPixels</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> outPixels <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span>inPixels<span class="token punctuation">.</span>length<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">boolean</span> index <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> bitmap <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> bitmap <span class="token operator">&lt;</span> height<span class="token punctuation">;</span> <span class="token operator">++</span>bitmap<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> col <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> col <span class="token operator">&lt;</span> width<span class="token punctuation">;</span> <span class="token operator">++</span>col<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">int</span> var21 <span class="token operator">=</span> bitmap <span class="token operator">*</span> width <span class="token operator">+</span> col<span class="token punctuation">;</span>
            <span class="token keyword">int</span> r1 <span class="token operator">=</span> inPixels<span class="token punctuation">[</span>var21<span class="token punctuation">]</span> <span class="token operator">&gt;&gt;</span> <span class="token number">16</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
            <span class="token keyword">int</span> g1 <span class="token operator">=</span> inPixels<span class="token punctuation">[</span>var21<span class="token punctuation">]</span> <span class="token operator">&gt;&gt;</span> <span class="token number">8</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
            <span class="token keyword">int</span> b1 <span class="token operator">=</span> inPixels<span class="token punctuation">[</span>var21<span class="token punctuation">]</span> <span class="token operator">&amp;</span> <span class="token number">255</span><span class="token punctuation">;</span>
            <span class="token keyword">int</span> cIndex <span class="token operator">=</span> <span class="token function">getCloseColor</span><span class="token punctuation">(</span>r1<span class="token punctuation">,</span> g1<span class="token punctuation">,</span> b1<span class="token punctuation">)</span><span class="token punctuation">;</span>
            outPixels<span class="token punctuation">[</span>var21<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">16777216</span> <span class="token operator">|</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">&lt;&lt;</span> <span class="token number">16</span> <span class="token operator">|</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">&lt;&lt;</span> <span class="token number">8</span> <span class="token operator">|</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> ergb <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{<!-- --></span>r1 <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span> g1 <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">,</span> b1 <span class="token operator">-</span> COLOR_PALETTE<span class="token punctuation">[</span>cIndex<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
            <span class="token keyword">float</span> e1<span class="token punctuation">;</span>
            <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> rgb4<span class="token punctuation">;</span>
            <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> rgb5<span class="token punctuation">;</span>
            <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> rgb6<span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>method <span class="token operator">==</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                e1 <span class="token operator">=</span> <span class="token number">0.4375F</span><span class="token punctuation">;</span>
                <span class="token keyword">float</span> rgb1 <span class="token operator">=</span> <span class="token number">0.3125F</span><span class="token punctuation">;</span>
                <span class="token keyword">float</span> rgb2 <span class="token operator">=</span> <span class="token number">0.1875F</span><span class="token punctuation">;</span>
                <span class="token keyword">float</span> rgb3 <span class="token operator">=</span> <span class="token number">0.0625F</span><span class="token punctuation">;</span>
                rgb4 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                rgb5 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                rgb6 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb2<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> rgb41 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb3<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> rgb4<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb5<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb6<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb41<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                <span class="token keyword">if</span><span class="token punctuation">(</span>method <span class="token operator">!=</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                    <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">IllegalArgumentException</span><span class="token punctuation">(</span><span class="token string">"Not Supported Dither Mothed!!"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>

                e1 <span class="token operator">=</span> <span class="token number">0.125F</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> var23 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> var24 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> var25 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                rgb4 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                rgb5 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                rgb6 <span class="token operator">=</span> <span class="token function">getPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">,</span> e1<span class="token punctuation">,</span> ergb<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> var23<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">,</span> bitmap<span class="token punctuation">,</span> var24<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> var25<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb4<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span> rgb5<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">setPixel</span><span class="token punctuation">(</span>inPixels<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> col<span class="token punctuation">,</span> bitmap <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">,</span> rgb6<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token class-name">Bitmap</span> var22 <span class="token operator">=</span> <span class="token class-name">Bitmap</span><span class="token punctuation">.</span><span class="token function">createBitmap</span><span class="token punctuation">(</span>outPixels<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> width<span class="token punctuation">,</span> width<span class="token punctuation">,</span> height<span class="token punctuation">,</span> <span class="token class-name">Config</span><span class="token punctuation">.</span>RGB_565<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> var22<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token class-name">String</span> <span class="token function">splitArabic</span><span class="token punctuation">(</span><span class="token class-name">String</span> input<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">StringBuilder</span> sb <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span><span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> arabics <span class="token operator">=</span> input<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"\\n"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> i<span class="token punctuation">;</span>
    <span class="token keyword">int</span> childStringLength<span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>arabics<span class="token punctuation">.</span>length <span class="token operator">==</span> <span class="token number">1</span> <span class="token operator">&amp;&amp;</span> arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&gt;</span> sPaperWidth<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        i <span class="token operator">=</span> arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">/</span> sPaperWidth<span class="token punctuation">;</span>
        childStringLength <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>

        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> childStringLength <span class="token operator">&lt;=</span> i<span class="token punctuation">;</span> <span class="token operator">++</span>childStringLength<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">substring</span><span class="token punctuation">(</span>j<span class="token punctuation">,</span> sPaperWidth <span class="token operator">*</span> childStringLength<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            j <span class="token operator">+=</span> sPaperWidth<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">if</span><span class="token punctuation">(</span>sb<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&gt;=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token char">'\n'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        childStringLength <span class="token operator">=</span> arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">%</span> sPaperWidth<span class="token punctuation">;</span>
        sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">substring</span><span class="token punctuation">(</span>arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> childStringLength<span class="token punctuation">,</span> arabics<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token function">splitArabic</span><span class="token punctuation">(</span>sb<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">for</span><span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> arabics<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            childStringLength <span class="token operator">=</span> arabics<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>childStringLength <span class="token operator">&gt;</span> sPaperWidth<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token function">splitArabic</span><span class="token punctuation">(</span>arabics<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token function">addSpaceAfterArabicString</span><span class="token punctuation">(</span>arabics<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">,</span> sPaperWidth <span class="token operator">-</span> childStringLength<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">return</span> sb<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token class-name">String</span> <span class="token function">addSpaceAfterArabicString</span><span class="token punctuation">(</span><span class="token class-name">String</span> arabic<span class="token punctuation">,</span> <span class="token keyword">int</span> number<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">StringBuilder</span> sb <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span><span class="token number">65</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>arabic<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> number<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token char">' '</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    sb<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token char">'\n'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> sb<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token class-name">String</span> <span class="token function">reverseLetterAndNumber</span><span class="token punctuation">(</span><span class="token class-name">String</span> input<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">StringBuilder</span> sb <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Matcher</span> matcher <span class="token operator">=</span> pattern<span class="token punctuation">.</span><span class="token function">matcher</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">while</span><span class="token punctuation">(</span>matcher<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token class-name">String</span> matcherString <span class="token operator">=</span> matcher<span class="token punctuation">.</span><span class="token function">group</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> matcherStart <span class="token operator">=</span> matcher<span class="token punctuation">.</span><span class="token function">start</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> matcherEnd <span class="token operator">=</span> matcher<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        sb<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span>matcherStart<span class="token punctuation">,</span> matcherEnd<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span>matcherString<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> sb<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">string2Cp864</span><span class="token punctuation">(</span><span class="token class-name">String</span> arabicString<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> originUnicode <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Integer</span><span class="token punctuation">[</span>arabicString<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> outputUnicode <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Integer</span><span class="token punctuation">[</span>arabicString<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> outputChars <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Integer</span><span class="token punctuation">[</span>originUnicode<span class="token punctuation">.</span>length<span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token function">copy</span><span class="token punctuation">(</span>arabicString<span class="token punctuation">.</span><span class="token function">toCharArray</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> originUnicode<span class="token punctuation">,</span> arabicString<span class="token punctuation">.</span><span class="token function">length</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ArrayList</span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token punctuation">(</span><span class="token class-name">Arrays</span><span class="token punctuation">.</span><span class="token function">asList</span><span class="token punctuation">(</span>originUnicode<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">List</span> list1 <span class="token operator">=</span> <span class="token class-name">Hyphen</span><span class="token punctuation">(</span>list<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list1 <span class="token operator">=</span> <span class="token class-name">Deformation</span><span class="token punctuation">(</span>list1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Collections</span><span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span>list1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list1<span class="token punctuation">.</span><span class="token function">toArray</span><span class="token punctuation">(</span>outputUnicode<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">char</span><span class="token punctuation">[</span><span class="token punctuation">]</span> chs <span class="token operator">=</span> <span class="token function">integer2Character</span><span class="token punctuation">(</span>outputUnicode<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> cp864bytes <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token keyword">try</span> <span class="token punctuation">{<!-- --></span>
        cp864bytes <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span>chs<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">"cp864"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">UnsupportedEncodingException</span> var8<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        var8<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> cp864bytes<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">char</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token function">integer2Character</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> integers<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">char</span><span class="token punctuation">[</span><span class="token punctuation">]</span> chs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">char</span><span class="token punctuation">[</span>integers<span class="token punctuation">.</span>length<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> integers<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>integers<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            chs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">char</span><span class="token punctuation">)</span>integers<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
            chs<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">32</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> chs<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">copy</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token punctuation">[</span><span class="token punctuation">]</span> array<span class="token punctuation">,</span> <span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> originUnicode<span class="token punctuation">,</span> <span class="token keyword">int</span> length<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> length<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        originUnicode<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>array<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> <span class="token class-name">Hyphen</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> list<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> list<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>list<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">1604</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">switch</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>list<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                <span class="token keyword">case</span> <span class="token number">1570</span><span class="token operator">:</span>
                    list<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token number">17442</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    list<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token keyword">case</span> <span class="token number">1571</span><span class="token operator">:</span>
                    list<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token number">17443</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    list<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">case</span> <span class="token number">1572</span><span class="token operator">:</span>
                <span class="token keyword">case</span> <span class="token number">1574</span><span class="token operator">:</span>
                <span class="token keyword">default</span><span class="token operator">:</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token keyword">case</span> <span class="token number">1573</span><span class="token operator">:</span>
                    list<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token number">17445</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    list<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token keyword">break</span><span class="token punctuation">;</span>
                <span class="token keyword">case</span> <span class="token number">1575</span><span class="token operator">:</span>
                    list<span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span>i<span class="token punctuation">,</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span><span class="token number">17447</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    list<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> list<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> <span class="token class-name">Deformation</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> inputlist<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">boolean</span> flag <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token class-name">ArrayList</span> outputlist <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">HashMap</span> formHashTable <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">int</span> i<span class="token punctuation">;</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">40</span><span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        formHashTable<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span>theSet0<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token class-name">FormatTable</span><span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span>i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> inputlist<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">boolean</span> inSet1<span class="token punctuation">;</span>
            <span class="token keyword">boolean</span> inSet2<span class="token punctuation">;</span>
            <span class="token keyword">int</span> var8<span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>i <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                inSet1 <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
                inSet2 <span class="token operator">=</span> <span class="token function">compare</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                var8 <span class="token operator">=</span> <span class="token class-name">Flag</span><span class="token punctuation">(</span>inSet1<span class="token punctuation">,</span> inSet2<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>i <span class="token operator">==</span> inputlist<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
                inSet1 <span class="token operator">=</span> <span class="token function">compare</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                inSet2 <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
                var8 <span class="token operator">=</span> <span class="token class-name">Flag</span><span class="token punctuation">(</span>inSet1<span class="token punctuation">,</span> inSet2<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
                inSet1 <span class="token operator">=</span> <span class="token function">compare</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                inSet2 <span class="token operator">=</span> <span class="token function">compare</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                var8 <span class="token operator">=</span> <span class="token class-name">Flag</span><span class="token punctuation">(</span>inSet1<span class="token punctuation">,</span> inSet2<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> a <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span>formHashTable<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            outputlist<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>a<span class="token punctuation">[</span>var8<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{<!-- --></span>
            outputlist<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">)</span>inputlist<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> outputlist<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">compare</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> input<span class="token punctuation">,</span> <span class="token keyword">int</span> i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token class-name">ArrayList</span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>theSet0<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>theSet1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>theSet2<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token function">findInArray</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span>list<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">,</span> input<span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">findInArray</span><span class="token punctuation">(</span><span class="token class-name">Integer</span><span class="token punctuation">[</span><span class="token punctuation">]</span> integer<span class="token punctuation">,</span> <span class="token keyword">int</span> input<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> j <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> j <span class="token operator">&lt;</span> integer<span class="token punctuation">.</span>length<span class="token punctuation">;</span> <span class="token operator">++</span>j<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>integer<span class="token punctuation">[</span>j<span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> input<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">int</span> <span class="token class-name">Flag</span><span class="token punctuation">(</span><span class="token keyword">boolean</span> set1<span class="token punctuation">,</span> <span class="token keyword">boolean</span> set2<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">return</span> set1 <span class="token operator">&amp;&amp;</span> set2<span class="token operator">?</span><span class="token number">3</span><span class="token operator">:</span><span class="token punctuation">(</span><span class="token operator">!</span>set1 <span class="token operator">&amp;&amp;</span> set2<span class="token operator">?</span><span class="token number">2</span><span class="token operator">:</span><span class="token punctuation">(</span>set1 <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span>set2<span class="token operator">?</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">setPaperWidth</span><span class="token punctuation">(</span><span class="token keyword">int</span> paperWidth<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    sPaperWidth <span class="token operator">=</span> paperWidth<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token class-name">ByteTo_byte</span><span class="token punctuation">(</span><span class="token class-name">Vector</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Byte</span><span class="token punctuation">&gt;</span></span> vector<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">int</span> len <span class="token operator">=</span> vector<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">byte</span><span class="token punctuation">[</span>len<span class="token punctuation">]</span><span class="token punctuation">;</span>

    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> len<span class="token punctuation">;</span> <span class="token operator">++</span>i<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        data<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">Byte</span><span class="token punctuation">)</span>vector<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">byteValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> data<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">int</span> <span class="token function">getMethod</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    <span class="token keyword">return</span> method<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setMethod</span><span class="token punctuation">(</span><span class="token keyword">int</span> method<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
    method <span class="token operator">=</span> method<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">enum</span> ENABLE <span class="token punctuation">{<!-- --></span>
    <span class="token function">OFF</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">ON</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token keyword">final</span> <span class="token keyword">int</span> value<span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token function">ENABLE</span><span class="token punctuation">(</span><span class="token keyword">int</span> value<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>value <span class="token operator">=</span> value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">byte</span> <span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token keyword">byte</span><span class="token punctuation">)</span><span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
  • 554
  • 555
  • 556
  • 557
  • 558
  • 559
  • 560
  • 561
  • 562
  • 563
  • 564
  • 565
  • 566
  • 567
  • 568
  • 569
  • 570
  • 571
  • 572
  • 573
  • 574
  • 575
  • 576
  • 577
  • 578
  • 579
  • 580
  • 581
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • 589
  • 590
  • 591
  • 592
  • 593
  • 594
  • 595
  • 596
  • 597
  • 598
  • 599
  • 600
  • 601
  • 602
  • 603
  • 604
  • 605
  • 606
  • 607
  • 608
  • 609
  • 610
  • 611
  • 612
  • 613

接下来就是设置具体的打印模板及内容

//标签打印
LabelCommand tsc = new LabelCommand();
tsc.addSize(40, 30); // 设置标签尺寸,按照实际尺寸设置
tsc.addGap(2); // 设置标签间隙,按照实际尺寸设置,如果为无间隙纸则设置为0
tsc.addDirection(LabelCommand.DIRECTION.BACKWARD, LabelCommand.MIRROR.NORMAL);// 设置打印方向
tsc.addReference(0, 0);// 设置原点坐标
tsc.addTear(LabelUtils.ENABLE.ON); // 撕纸模式开启

tsc.addCls();// 清除打印缓冲区
// 绘制简体中文
tsc.addText(20, 20, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
" 天猫超市");
tsc.addText(20, 50, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
"商品:农夫山泉");
tsc.addText(20, 80, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
"规格:箱");
tsc.addText(20, 110, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
"金额:¥16.00");
tsc.addText(20, 140, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
"时间:2017/05/19 15:00");
tsc.addText(20, 170, LabelCommand.FONTTYPE.SIMPLIFIED_CHINESE, LabelCommand.ROTATION.ROTATION_0, LabelCommand.FONTMUL.MUL_1, LabelCommand.FONTMUL.MUL_1,
"电话:18818181818");

// 绘制图片
// Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.product_000001);
// tsc.addBitmap(20, 50, LabelCommand.BITMAP_MODE.OVERWRITE, b.getWidth(), b);

// 绘制二维码
// tsc.addQRCode(250, 80, LabelCommand.EEC.LEVEL_L, 5, LabelCommand.ROTATION.ROTATION_0, " www.gg.com.cn");

// 绘制条形码
// tsc.add1DBarcode(20, 250, LabelCommand.BARCODETYPE.CODE128, 100, LabelCommand.READABEL.EANBEL, LabelCommand.ROTATION.ROTATION_0, "printer");

tsc.addPrint(1, 1); // 打印标签
tsc.addSound(2, 100); // 打印标签后 蜂鸣器响

// tsc.addCashdrwer(LabelCommand.FOOT.F5, 255, 255);

Vector<Byte> datas = tsc.getCommand(); // 发送数据
byte[] bytes = LabelUtils.ByteTo_byte(datas);

String str = Base64.encodeToString(bytes, Base64.DEFAULT);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

最后就是将这些指令数据传输给打印设备

传输方式有USB、BlueTooth、NetWork等,这里给出蓝牙传输的例子

byte[] decode_datas = Base64.decode(str, Base64.DEFAULT);

BluetoothManager btManager = BluetoothManager.getInstance();
if (btManager.hasConnectedDevice()) {
btManager.printText(decode_datas, new BluetoothManager.OnPrintListener() {
@Override
public void onPrintFinished() {
showPrintFinished();
}

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">onPrintFail</span><span class="token punctuation">(</span><span class="token keyword">final</span> <span class="token class-name">BluetoothDevice</span> device<span class="token punctuation">)</span> <span class="token punctuation">{<!-- --></span>
        <span class="token function">showPrintFailed</span><span class="token punctuation">(</span>device<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

打印效果

这里写图片描述

    <div id="blogExtensionBox" style="width:400px;margin:auto;margin-top:12px" class="blog-extension-box"><div class="blog_extension blog_extension_type2" id="blog_extension">
      <div class="extension_official" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.6471&quot;}">
      <div class="blog_extension_card_left">
        <img src="https://img-blog.csdnimg.cn/755a6a618dfb4df9a8189178582cfd06.jpeg" alt="">
      </div>
      <div class="blog_extension_card_cont">
        <span class="text">资深Android开发工程师</span>
        <div class="blog_extension_card_cont_r">
          <img class="weixin" src="https://g.csdnimg.cn/extension-box/1.1.6/image/weixin.png" alt="">
          <span>微信名片</span>
        </div>
      </div>
      <img class="blog_extension_card_right" src="https://g.csdnimg.cn/extension-box/1.1.6/image/ic_move.png" alt="">
    </div></div></div>
</article>
posted @ 2024-04-12 14:42  一贴灵  阅读(51)  评论(0编辑  收藏  举报
学以致用,效率第一