Example #1
0
        protected virtual int CodeRecordA(int rectype, JB2Dictionary jim, JB2Shape xjshp)
        {
            Bitmap bm      = null;
            int    shapeno = -1;

            rectype = CodeRecordType(rectype);

            JB2Shape jshp = xjshp;

            switch (rectype)
            {
            case NewMarkLibraryOnly:
            case MatchedRefineLibraryOnly:
            {
                if (!_encoding)
                {
                    jshp = new JB2Shape().Init(-1);
                }
                else if (jshp == null)
                {
                    jshp = new JB2Shape();
                }

                bm = jshp.Bitmap;

                break;
            }
            }

            switch (rectype)
            {
            case StartOfData:
            {
                CodeImageSize(jim);
                CodeEventualLosslessRefinement();

                if (!_encoding)
                {
                    InitLibrary(jim);
                }

                break;
            }

            case NewMarkLibraryOnly:
            {
                CodeAbsoluteMarkSize(bm, 4);
                CodeBitmapDirectly(bm);

                break;
            }

            case MatchedRefineLibraryOnly:
            {
                int match = CodeMatchIndex(jshp.Parent, jim);

                if (!_encoding)
                {
                    jshp.Parent = Convert.ToInt32((Lib2Shape[match]));
                }

                Bitmap    cbm    = jim.GetShape(jshp.Parent).Bitmap;
                Rectangle lmatch = (Rectangle)_libinfo[match];
                CodeRelativeMarkSize(bm, (1 + lmatch.Left) - lmatch.Right, (1 + lmatch.Top) - lmatch.Bottom, 4);
                CodeBitmapByCrossCoding(bm, cbm, jshp.Parent);

                break;
            }

            case PreservedComment:
            {
                jim.Comment = CodeComment(jim.Comment);

                break;
            }

            case RequiredDictOrReset:
            {
                if (!GotStartRecordP)
                {
                    CodeInheritedShapeCount(jim);
                }
                else
                {
                    ResetNumcoder();
                }

                break;
            }

            case EndOfData:
                break;

            default:
                throw new ArgumentException("Image bad type");
            }

            if (!_encoding)
            {
                switch (rectype)
                {
                case NewMarkLibraryOnly:
                case MatchedRefineLibraryOnly:
                {
                    if (xjshp != null)
                    {
                        jshp = jshp.Duplicate();
                    }

                    shapeno = jim.AddShape(jshp);
                    AddLibrary(shapeno, jshp);

                    break;
                }
                }
            }

            return(rectype);
        }