Esempio n. 1
0
        //完成最后一系列工作,并把缓冲区的内容转成字节数据返回
        public static byte[] POS_Print()
        {
            if (PrintDirection != 0)
            {
                SYS_SetPrintDirection(0);
            }

            int nHeight    = PageBuffer.Length;
            int nWidth     = PageBuffer[0].Length;
            int blukHeight = 96;
            int blukSum    = (nHeight + blukHeight - 1) / blukHeight;
            int byteLength = 8 * blukSum + (nWidth + 7) / 8 * ((nHeight + 7) / 8 * 8);

            byte[] latestData = new byte[byteLength];
            int offset        = 0;

            byte[][] desData;
            desData = CACULATE.getSampleDesData(blukHeight, nWidth);

            for (int i = 0; i < nHeight; i = i + blukHeight)
            {
                if ((nHeight - i > 0) & (nHeight - i < blukHeight))
                {
                    desData = CACULATE.getSampleDesData(nHeight - i, nWidth);
                }

                CACULATE.CACU_CutToData(PageBuffer, i, 0, desData);
                byte[] temp = CACULATE.CACU_PixDataToPrintedCommand(desData, 0);
                temp.CopyTo(latestData, offset);
                offset += temp.Length;
            }
            return(latestData);
        }
Esempio n. 2
0
        //将源数据按指定的宽高分割成小方格图片,以每个图片为单位,返回光栅数据
        private static byte[] TAC_CutToGridAndTurnToByte(byte[][] orgData, int nPerHeight, int nPerWidth, int nLines, int nClos)
        {
            //测试时为bFontWidth = 24,bFontHeight = 24,bLines = 12, bClos = 16;
            //12行,每行16个汉字
            int nHeight = nPerHeight * nLines;
            int nWidht  = nPerWidth * nClos;

            byte[][] tempGridData = new byte[nPerHeight][];
            for (int i = 0; i < nPerHeight; i++)
            {
                tempGridData[i] = new byte[nPerWidth];
            }
            int nPerGridByte = ((nPerWidth + 7) / 8) * nPerHeight;

            byte[] bWordsByte = new byte[nPerGridByte * nLines * nClos];
            int    k          = 0;

            for (int i = 0; i < nHeight; i += nPerHeight)
            {
                for (int j = 0; j < nWidht; j += nPerWidth)
                {
                    CACULATE.CACU_CutToData(orgData, i, j, tempGridData);//已经获得光栅的点阵数据了
                    TAC_TurnBitToByte(tempGridData).CopyTo(bWordsByte, k);
                    k += nPerGridByte;
                }
            }
            return(bWordsByte);
        }