android藍芽列印黑白圖片的ESC命令

來源:互聯網
上載者:User

標籤:android   blog   http   color   ar   for   sp   2014   問題   

問題描述
我用熱敏印表機的ESC * 命令列印圖片時為什麼列印後的是亂碼。代碼是從C#中修改的
Bitmap bt = BitmapFactory.decodeFile(MainActivity.path + message);if (bt !=null){
mService.write(ESC_INIT);
//mService.write(ESC_STANDARD);
byte[] data = new byte[] { 0x1B, 0x33, 0x00 };  
mService.write(data);
            //socket.Send(data, data.Length, 0);  
            data[0] = 0x00;  
            data[1] = 0x00;  
            data[2] = 0x00;    // Clear to Zero. 
         // ESC * m nL nH 點陣圖   
            byte[] escBmp = new byte[] { 0x1B, 0x2A, 0x00, 0x00, 0x00 };  
            int pixelColor;
            escBmp[2] = 0x21;  
  
            //nL, nH   
            escBmp[3] = (byte)(bt.getWidth() % 256);  
            escBmp[4] = (byte)(bt.getWidth() / 256);  
            
         // data   
            for (int i = 0; i < (bt.getHeight() / 24 + 1); i++)  
            { 
            mService.write(escBmp);  
                for (int j = 0; j < bt.getWidth(); j++)  
                {  
                    for (int k = 0; k < 24; k++)  
                    {  
                        if (((i * 24) + k) < bt.getHeight())   // if within the BMP size   
                        {  
                            pixelColor = bt.getPixel(j, (i * 24) + k);  
                            if (pixelColor != -1)  
                            {  
                                data[k / 8] += (byte)(-128 >> (k % 8));  
                            //data[k / 8] += 1;
                            }  
                        }  
                    }
                    
                    mService.write(data);  
                    data[0] = 0x00;  
            data[1] = 0x00;  
            data[2] = 0x00;    // Clear to Zero.   
                }  
                
            
mService.write(LF_ENTER);

                //send = Encoding.GetEncoding("gb18030").GetBytes("\n");         
            } // data   解決方案1
lz 問題結局了嗎 解決方案2
我也沒有解決 糾結啊 想到什麼其他思路嗎。 解決方案3
能留個連絡方式 一起交流嗎。 解決方案4
交流的有沒有結果,有結果麻煩發一下

android藍芽列印黑白圖片的ESC命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.