Example #1
0
        private void  BuildDecodeRecs()
        {
            if (convTable4BitTo8Bit == null)
            {
                BuildConversionTables();
            }

            decodeRecs = new DecodeOpRec[256];
            int x = 0;

            for (x = 0; x < decodeRecs.Length; x++)
            {
                decodeRecs[x] = new DecodeOpRec((Byte)x, convTable4BitTo8Bit);
            }

            decodeRawBytes = new DecodeRawByte[256];
            for (x = 0; x < decodeRawBytes.Length; x++)
            {
                decodeRawBytes[x] = new DecodeRawByte((byte)x, convTable4BitTo8Bit);
            }
        } /* BuildDecodeRecs */
Example #2
0
        } /* SkipNextScanLine */

        override public void  ReadNextScanLine(byte[]  scanLine)
        {
            bool eol = false;
            int  idx = 0;

            byte rec = GetNextByte();

            while ((!eof) && (!eol))
            {
                DecodeOpRec dr = decodeRecs[rec];
                switch (dr.opCode)
                {
                case  0:// End of Line
                    eol = true;
                    break;

                case  1:// Text Block
                {
                    ProcessTextBlock(dr);
                }
                break;


                case  2:// Instrument Data
                {
                    //
                    ProcessInstrumentData(dr);
                }
                break;

                case  3:
                    break; // Unused.

                case  4:   // Run Length of 2
                case  5:   // Run Length of 3
                case  6:   // Run Length of 4
                case  7:   // Run Length of 5
                case  8:   // Run Length of 6
                case  9:   // Run Length of 7
                {
                    int endIdx = idx + (int)dr.runLength - 1;
                    if (endIdx >= scanLine.Length)
                    {
                        endIdx = scanLine.Length - 1;
                    }
                    while (idx <= endIdx)
                    {
                        scanLine[idx] = dr.runLengthChar;
                        ++idx;
                    }
                }
                break;

                case 10:
                {
                    // Will need to get next byte to determine runLength;
                    int runLen = GetNextByte() + 1;
                    int endIdx = idx + runLen - 1;
                    if (endIdx >= scanLine.Length)
                    {
                        endIdx = scanLine.Length - 1;
                    }
                    while (idx <= endIdx)
                    {
                        scanLine[idx] = dr.runLengthChar;
                        ++idx;
                    }
                }
                break;


                case  11:// Raw-String (1 Pixel Length).
                {
                    scanLine[idx] = dr.rawPixel;
                    ++idx;
                }
                break;


                case  12:// Raw-String (Even length 2 thru 32).
                {
                    byte[] buff = GetNextBuff((uint)dr.rawStringBytesToRead);
                    if (buff != null)
                    {
                        for (int x = 0; x < buff.Length; ++x)
                        {
                            decodeRawBytes[buff[x]].FillIntoScanLine(scanLine, ref idx);
                        }
                    }
                }
                break;


                case  13:// Raw-String (Odd Length 1 thru 513).
                {
                    byte nextByte = GetNextByte();

                    DecodeRawByte rb          = decodeRawBytes[nextByte];
                    uint          bytesToRead = (dr.bytesToReadHighOrder + rb.lower4Bits) + 1;
                    if (idx < scanLine.Length)
                    {
                        scanLine[idx] = rb.pixel1;
                    }

                    byte[] buff = GetNextBuff((uint)bytesToRead);
                    if (buff != null)
                    {
                        for (int x = 0; x < buff.Length; ++x)
                        {
                            decodeRawBytes[buff[x]].FillIntoScanLine(scanLine, ref idx);
                        }
                    }
                }
                break;


                case  14:
                    break; // Unused.


                case  15:
                    break; // Unused.
                }

                if (!eol)
                {
                    rec = GetNextByte();
                }
            }
        } /* ReadNextScanLine */